Skip to content

Instantly share code, notes, and snippets.

@dannymcc
Created December 26, 2012 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannymcc/4381037 to your computer and use it in GitHub Desktop.
Save dannymcc/4381037 to your computer and use it in GitHub Desktop.
Automatic cleanup script for Windows XP
@echo off
ECHO*****************************************************************************************
ECHO Please close all running programs, and plug into A/C power if you are on a laptop.
ECHO This will take a LONG time to complete.
ECHO *****************************************************************************************
REM This batch will set Check Disk to run after reboot, run Disk Cleanup, delete temp files,
REM run Disk Defragmenter, delete this file, and reboot the machine, starting Check Disk
REM Check Disk
REM ================
chkdsk /r
REM Disk Cleanup
REM ================
c:\windows\system32\cleanmgr.exe /dc /sagerum: 1
REM Oilchange
REM ================
del /a /s /q %windir%\temp & md %windir%\temp
del /a /s /q %userprofile%\recent\*.*
del /a /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /a /s /q "%userprofile%\Local Settings\Temp\*.*"
del /a /s /q "%userprofile%\recent\*.*"
del /a /s /q %systemdrive%\*.tmp
del /a /s /q %systemdrive%\*._mp
del /a /s /q %systemdrive%\*.log
del /a /s /q %systemdrive%\*.gid
del /a /s /q %systemdrive%\*.chk
del /a /s /q %systemdrive%\*.old
del /a /s /q %systemdrive%\recycled\*.*
del /a /s /q %windir%\*.bak
del /a /s /q %windir%\prefetch\*.*
REM Defragmenter
REM ================
defrag C: -f
defrag D: -f
REM Restart
REM ================
shutdown -r -f
REM Delete
REM ================
DEL FILENAME.bat
EXIT
To save, copy into Notepad, save as FILENAME.bat
In case you'd like a stripped down version w/o comments:
@echo off
chkdsk /r
c:\windows\system32\cleanmgr.exe /dc /sagerum: 1
del /a /s /q %windir%\temp & md %windir%\temp
del /a /s /q %userprofile%\recent\*.*
del /a /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /a /s /q "%userprofile%\Local Settings\Temp\*.*"
del /a /s /q "%userprofile%\recent\*.*"
del /a /s /q %systemdrive%\*.tmp
del /a /s /q %systemdrive%\*._mp
del /a /s /q %systemdrive%\*.log
del /a /s /q %systemdrive%\*.gid
del /a /s /q %systemdrive%\*.chk
del /a /s /q %systemdrive%\*.old
del /a /s /q %systemdrive%\recycled\*.*
del /a /s /q %windir%\*.bak
del /a /s /q %windir%\prefetch\*.*
defrag C: -f
defrag D: -f
shutdown -r -f
DEL FILENAME.bat
EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment