Skip to content

Instantly share code, notes, and snippets.

@chetan
Created January 11, 2014 03:43
Show Gist options
  • Save chetan/8366728 to your computer and use it in GitHub Desktop.
Save chetan/8366728 to your computer and use it in GitHub Desktop.
Handy script for cleaning up old temporary files on windows. ReportQueue (from error reporting) gets especially large...
@echo off
IF EXIST c:\windows\temp\ (
forfiles /p "C:\Windows\Temp" /s /m *.* /D -7 /C "cmd /c del /Q @path"
)
IF EXIST "C:\Users\" (
for /D %%x in ("C:\Users\*") do (
forfiles /p "%%x\AppData\Local\Temp" /s /m *.* /D -7 /C "cmd /c del /Q @path"
forfiles /p "%%x\AppData\Local\Microsoft\Windows\Temporary Internet Files" /s /m *.* /D -7 /C "cmd /c del /Q @path"
forfiles /p "%%x\AppData\Local\Microsoft\Windows\WER\ReportQueue" /s /m *.* /C "cmd /c del /Q @path"
)
)