Tag Archives: Windows batch file to clean temprary files

Script to clean temporary files and window update for fasten the Window machines

Script to fast the window machine by clearing temporary files and run window update

The following script first clear the temp locations of windows and then it clears the temporary location for the user from which it run. Then it will run the window update command to update the window to its latest window patch. It will also ask for delete the recycle bin data from the recyclebin.

Save the following file in batch format ( bat file)

@echo off

IF EXIST c:\windows\temp\ del /f /s /q c:\windows\temp\

DEL /f /s /q %temp%\

IF EXIST "C:\Users\" (
    for /D %%x in ("C:\Users\*") do ( 
        del /f /s /q "%%x\AppData\Local\Temp\" 
        del /f /s /q "%%x\AppData\Local\Microsoft\Windows\Temporary Internet Files\" 
    )
)

rd /s c:\$Recycle.Bin
rd /s /q %systemdrive%\$Recycle.bin
del c:\windows\prefetch
wuauclt /detectnow /updatnow

Double click on the window batch file will start the process and you can schedule it on your task scheduler for regular or weekly run.