This script will clean the temporary folders, defrag all fixed drives and shutdown the computer. @echo off del /f /q "%temp%" rd /s /q "%temp%" if not exist "%temp%" md "%temp%" del /f /q "%windir%\temp" rd /s /q "%windir%\temp" if not exist "%windir%\temp" md "%windir%\temp" Defrag /c /u /v shutdown /f /s /t 0