Batch file to keep computer clean
Posted: 11 Feb 2011 17:52
I am setting up a computer for my nephew , have had it now for a while,and am wanting to create a batch file that he can run once a week from his desktop to help keep his computer halfway clean. Here is what I would like to do:
On the C:\drive I would like to have these deleted:
all .tmp files
all ._mp files
all .log files
all .gid files
all .chk files
all .old files
all .bak files
all files in Windows\Temp folder
all files in Local Settings\Temp folder
I also have a hidden drive K: that I have moved my Temp folder to and have also moved the Temporary Internet File folder there, so I would also like to have the following deleted from the K: drive
all files and folders in K:\Temp
all files and folders in K:\Temp\Low
all files in K:\Temp\Temporary Internet Files folder
and I also would like to add the following to the end of this batch file:(This runs perfectdisk to defrag his drives)
@ECHO OFF
::Determine the path to the PerfectDisk program
Set Reg.Key=HKLM\Software\Microsoft\Windows\CurrentVersion\AppPaths\PerfectDisk.exe
Set Reg.Val=Path
For /F "Tokens=2*" %%A In ('Reg Query "%Reg.Key%" /v "%Reg.Val%" ^|
Find /I "%Reg.Val%"') Do Call Set PathDirectory=%%B
Set PerfectDiskPath=%PathDirectory%
::Perform a Smart Placement defrag on drive C:. Wait until complete
before returning control.
"%PerfectDiskPath%pdcmd" /AllDrives /SP /WAIT
::Shutdown Windows Force running aplications to close and wait for 10
seconds and then shutdown Windows
shutdown.exe -s -f -t 10
running Vista Ultimate 64 with 8 gigs ram, gtx 260 Graphics card, core 2 duo e8500
Any help to get this thing back to him would be appreciated
On the C:\drive I would like to have these deleted:
all .tmp files
all ._mp files
all .log files
all .gid files
all .chk files
all .old files
all .bak files
all files in Windows\Temp folder
all files in Local Settings\Temp folder
I also have a hidden drive K: that I have moved my Temp folder to and have also moved the Temporary Internet File folder there, so I would also like to have the following deleted from the K: drive
all files and folders in K:\Temp
all files and folders in K:\Temp\Low
all files in K:\Temp\Temporary Internet Files folder
and I also would like to add the following to the end of this batch file:(This runs perfectdisk to defrag his drives)
@ECHO OFF
::Determine the path to the PerfectDisk program
Set Reg.Key=HKLM\Software\Microsoft\Windows\CurrentVersion\AppPaths\PerfectDisk.exe
Set Reg.Val=Path
For /F "Tokens=2*" %%A In ('Reg Query "%Reg.Key%" /v "%Reg.Val%" ^|
Find /I "%Reg.Val%"') Do Call Set PathDirectory=%%B
Set PerfectDiskPath=%PathDirectory%
::Perform a Smart Placement defrag on drive C:. Wait until complete
before returning control.
"%PerfectDiskPath%pdcmd" /AllDrives /SP /WAIT
::Shutdown Windows Force running aplications to close and wait for 10
seconds and then shutdown Windows
shutdown.exe -s -f -t 10
running Vista Ultimate 64 with 8 gigs ram, gtx 260 Graphics card, core 2 duo e8500
Any help to get this thing back to him would be appreciated