Jump to content

Recommended Posts

Posted (edited)

Hi I have a few batch files here that need testing since currently something seems to be wrong with enviorment variables on my OS. Please test and tell me if they exit, do what they are made to do, etc. Also a big thanks to whoever helps me out.

Removed Legends for scripts since the forum hates long lines

Only Run the Attrib.cmd script please I don't want to be blamed for killing your box

Attrib.cmd

@ECHO OFF
:START
GOTO SYS


REM System Drive
REM --------------------------------
:SYS

GOTO DANDS


REM Documents And Settings
REM --------------------------------
:DANDS

attrib +H +S  "%ALLUSERSPROFILE%\ntuser.dat"
attrib +H +S  "%ALLUSERSPROFILE%\ntuser.dat.log"
attrib +H +S +R  "%SystemDrive%\Documents And Settings\Default User\Cookies\index.dat"
attrib +H +S  "%USERPROFILE%\ntuser.dat"
attrib +H +S  "%USERPROFILE%\ntuser.dat.log"

GOTO PROG


REM Program Files
REM --------------------------------
:PROG

GOTO WIN


REM Windows
REM --------------------------------
:WIN

attrib +H +S  "%SystemRoot%\system32\config\AppEvent.Evt"
attrib +H +S        "%SystemRoot%\system32\config\default"
attrib +H +S        "%SystemRoot%\system32\config\default.LOG"
attrib +H +S        "%SystemRoot%\system32\config\SAM"
attrib +H +S        "%SystemRoot%\system32\config\SAM.LOG"
attrib +H +S        "%SystemRoot%\system32\config\SecEvent.Evt"
attrib +H +S        "%SystemRoot%\system32\config\SECURITY"
attrib +H +S        "%SystemRoot%\system32\config\SECURITY.LOG"
attrib +H +S        "%SystemRoot%\system32\config\software"
attrib +H +S        "%SystemRoot%\system32\config\software.LOG"
attrib +H +S        "%SystemRoot%\system32\config\SysEvent.Evt"
attrib +H +S        "%SystemRoot%\system32\config\System"
attrib +H +S        "%SystemRoot%\system32\config\System.LOG"
attrib +H +S        "%SystemRoot%\WindowsUpdate.log"
attrib +H +S        "%SystemRoot%\Debug\PASSWD.LOG"
attrib +H +S        "%SystemRoot%\SoftwareDistribution\ReportingEvents.log"
attrib +H +S  "%SystemRoot%\SchedLgU.Txt"

GOTO POST


REM Post
REM --------------------------------
:POST

Echo Done Changing Attributes For System Files Files
pause

GOTO END
:END

Compact.cmd

@ECHO OFF
:START
GOTO SYS


REM System Drive
REM --------------------------------
:SYS

GOTO DANDS


REM Documents And Settings
REM --------------------------------
:DANDS

compact /C /S:  "%AllUserSProfile%\Application Data\Microsoft\User Account Pictures\Default Pictures"

GOTO PROG


REM Program Files
REM --------------------------------
:PROG

compact /C /S:  "%SystemDrive%\Program Files\Internet Explorer\Connection Wizard"

GOTO WIN


REM Windows
REM --------------------------------
:WIN

compact /C /S:  "%SystemRoot%\Connection Wizard"
compact /C /S:  "%SystemRoot%\Downloaded Installations"
compact /C /S:  "%SystemRoot%\Help"
compact /C /S:  "%SystemRoot%\inf"
compact /C /S:  "%SystemRoot%\PCHealth"
compact /C /S:  "%SystemRoot%\repair"
compact /C /S:  "%SystemRoot%\SoftwareDistribution"
compact /C /S:  "%SystemRoot%\Web"
compact /C /S:  "%SystemRoot%\system32\CatRoot"
compact /C /S:  "%SystemRoot%\system32\CatRoot2"
compact /C /S:  "%SystemRoot%\system32\ias"
compact /C /S:  "%SystemRoot%\system32\icsxml"
compact /C /S:  "%SystemRoot%\system32\MsDtc"
compact /C /S:  "%SystemRoot%\system32\mui"
compact /C /S:  "%SystemRoot%\system32\npp"
compact /C /S:  "%SystemRoot%\system32\ras"
compact /C /S:  "%SystemRoot%\system32\ReinstallBackups"
compact /C /S:  "%SystemRoot%\system32\Restore"

GOTO POST


REM Post
REM --------------------------------
:POST

Echo Done Compressing Infrequently Used Files
pause

GOTO END
:END

Removed Rd.cmd:

This can be done by editing the TXTSetup, DOSnet and layout files in your I386 dir.

Edited by Nmcsween

Posted

I am very curious what the folders you are removed are for? What would hey be used for? What programs/serivces ect rely on what you have listed here.

Your batch file looks very good and i would love to test it and perhaps add it to my unnatteded install. If you could only tell me the reasons you feel safe for removing what you are removing

thanks

Posted

Here is a VBS Script That does All Three Above Batches

I have only tested the attrib part and compact part, I did not

want to test the delete part.

Blue Text Are The Varibles For The Script

Green Text Are Array That Store The Various Information

Orange Text Is A Error Control

Red Text Is The Action It performs In The Loop

Purple Are The Loops For The Script

This Is to delete the file

Messagebox popup with built in timers"

'''' Those comment out the line like Rem In Batch files

Const READ_ONLY = 1,Hidden = 2

'''' Set Some Varibles For The Script

Dim Act, All_UP, All_UPAPM, Compact, Change, DelFolder, Fso

Dim SD, Sd_Pro, SR, SR_Sy32, SR_Sys32, User_P

Set Act = CreateObject("Wscript.shell")

Set Fso = CreateObject("Scripting.FileSystemObject")

SR = Act.ExpandEnvironmentStrings("%SystemRoot%")

SD = Act.ExpandEnvironmentStrings("%SystemDrive%")

All_UP = Act.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")

User_P = Act.ExpandEnvironmentStrings("%USERPROFILE%")

'''' Varibles For The Various Locations

All_UPAPM = All_UP & "\Application Data\Microsoft"

SR_Sys32 = SR & "\system32\config"

Sd_Pro = SD & "\Program Files"

SR_Sy32 = SR & "\system32"

  '''' Array That Stores All The Locations To Change The Attributes

  Change = Array (All_UP & "\ntuser.dat",All_UP & "\ntuser.log",_

  SD & "\Documents And Settings\Default User\Cookies\index.dat",_

  User_P & "\ntuser.dat",User_P & "\ntuser.log",SR_Sys32 & "\AppEvent.Evt",SR_Sys32 & "\default",_

  SR_Sys32 & "\default.LOG",SR_Sys32 & "\SAM",SR_Sys32 & "\SAM.LOG",SR_Sys32 & "\SecEvent.Evt",_

  SR_Sys32 & "\SECURITY",SR_Sys32 & "\SECURITY.LOG",SR_Sys32 & "\software",SR_Sys32 & "\software.LOG",_

  SR_Sys32 & "\SysEvent.Evt",SR_Sys32 & "\System",SR_Sys32 & "\System.LOG",SR & "\WindowsUpdate.log",_

  SR & "\Debug\PASSWD.LOG",SR & "\SoftwareDistribution\ReportingEvents.log")

'''' Goes Threw The Change Array And See If Not Set To Read Only Or Hidden

For Each StrChange In Change

  On Error Resume Next

    Set objReadOnlyFile = Fso.GetFile(StrChange)

    objReadOnlyFile.Attributes = objReadOnlyFile.Attributes XOR READ_ONLY

Next

For Each StrChange In Change

  On Error Resume Next

    Set objHiddenFile = Fso.GetFile(StrChange)

    objHiddenFile.Attributes = objHiddenFile.Attributes XOR Hidden

Next

Act.Popup "Completed The Script", 3, "Attrib Resets", 0 + 32

'''' Start The Compacting Of Files

Compact = Array(Sd_Pro & "\Internet Explorer\Connection Wizard", SR & "\Connection Wizard",_

SR & "\Downloaded Installations", SR & "\Help", SR & "\inf", SR & "\PCHealth", SR & "\repair",_

SR & "\SoftwareDistribution", SR & "\Web", SR_Sy32 & "\CatRoot", SR_Sy32 & "\CatRoot2",_

SR_Sy32 & "\ias", SR_Sy32 & "\icsxml", SR_Sy32 & "\MsDtc", SR_Sy32 & "\mui", SR_Sy32 & "\npp",_

SR_Sy32 & "\ras", SR_Sy32 & "\ReinstallBackups", SR_Sy32 & "\Restore" )

For Each StrCompact In Compact

Act.Run("%comspec% /c Echo Off && CLS && Color F2 && Mode 75,7 && Title Compact Files && compact /C /S:" & Chr(34) & StrCompact & Chr(34)),1,true

Next

Act.Popup "Completed Compacting The Files", 3,"Completed Compacting", 0 + 32

''''' Start Delete The Folders

'''' Check Before Delete The File

If Fso.FolderExists(SD & "\Documents and Settings\Default User\Local Settings\Application Data\Microsoft") Then

  Fso.DeleteFile(Chr(34) & SD & "\Documents and Settings\Default User\Local Settings\Application Data\Microsoft\*" & Chr(34))

Else '''' The Error Message

Act.Popup "Missing The Folder Or File" vbCrLf & "Location Is Not There", 5,"Error Missing",0 + 32

End If

''' Array For Folders To Delete

DelFolder - Array (All_UPAPM & "\Dr Watson",All_UPAPM & "\Media Index",All_UPAPM & "\Media Player",_

Sd_Pro & "\Common Files\Microsoft Shared\Stationery", Sd_Pro & "Internet Explorer\SIGNUP"

Sd_Pro & "\Online Services", Sd_Pro & "\Windows Media Player\Skins", Sd_Pro & "\WindowsUpdate", SR & "\addins",_

SR & "\Config", SR & "\Debug\UserMode", SR & "\Debug\WPD", SR & "\ime", SR & "\PeerNet", SR & "\Provisioning",_

SR & "\Registration\CRMLog", SR & "\security\logs", SR & "\security\database", SR & "\srchasst", SR_Sy32 & "\3com_dmi",_

SR_Sy32 & "\1025", SR_Sy32 & "\1028", SR_Sy32 & "\1031", SR_Sy32 & "\1037", SR_Sy32 & "\1041", SR_Sy32 & "\1053",_

SR_Sy32 & "\2052", SR_Sy32 & "\3076", SR_Sy32 & "\dhcp", SR_Sy32 & "\drivers\disdn", SR_Sy32 & "\drivers\etc",_

SR_Sy32 & "\export", SR_Sy32 & "\Lang", SR_Sy32 & "\SoftwareDistribution", SR_Sy32 & "\usmt", SR_Sy32 & "\wins")

''' Goes Threw The Array And Deletes The Folders

For Each StrDelFolder In DelFolder

  On Error Resume Next

Fso.DeleteFolder(Chr(34) & strDelFolder & Chr(34))

Next

Act.Popup "Completed The Remove The Folder", 3, "Finish Del Folders", 0 + 32

Posted

Now that you have a reply, what about telling us why…

  • you are giving files attributes which are not their defaults and asking us to do the same!

It would also be prudent in future to either check if a file exists prior to performing a task on it or alternatively redirect stderr. You may also wish to know that none of your goto statements are actually needed.

Posted (edited)
Now that you have a reply, what about telling us why…
  • you are giving files attributes which are not their defaults and asking us to do the same!

It would also be prudent in future to either check if a file exists prior to performing a task on it or alternatively redirect stderr. You may also wish to know that none of your goto statements are actually needed.

The Gotos arn't needed their just there for expandability (future error checking, etc).

As for changing attributes. Those files are Needed just to login. Such as "%SystemRoot%\system32\config\SAM" which is a peice of registry god knows why microsoft didn't label something windows can't boot without as non system....

Edited by Nmcsween

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...