Disk Cleanup

7 cleanup tasks that safely free disk space without affecting system stability. All operations are safe but not reversible (Recycle Bin already emptied, etc.), so review each task before running.

📁 Temporary Files

Removes files from %TEMP% and Windows\Temp folders. These are created by apps and Windows during normal operation and are safe to delete.

Location

%TEMP%\* and %WINDIR%\Temp\*

Command
Remove-Item -Recurse -Force "$env:TEMP\*"; Remove-Item -Recurse -Force "$env:WINDIR\Temp\*"

🗑 Recycle Bin

Empties the Recycle Bin on all drives, permanently deleting files that were previously sent to the Recycle Bin.

Location

All drives

Command
Clear-RecycleBin -Force

Prefetch Files

Deletes prefetch files (.pf) in Windows\Prefetch. These files speed up app startup but can accumulate over time. Safe to delete — Windows will rebuild them as needed.

Location

%WINDIR%\Prefetch\*

Command
Remove-Item -Force "$env:WINDIR\Prefetch\*"

🔽 Windows Update Cache

Clears the SoftwareDistribution\Download folder where Windows stores downloaded update files. Windows Update service is stopped/restarted automatically.

Location

%WINDIR%\SoftwareDistribution\Download\*

Command
net stop wuauserv; net stop bits; Remove-Item -Recurse -Force "$env:WINDIR\SoftwareDistribution\Download\*"; net start wuauserv; net start bits

🖼 Thumbnail Cache

Deletes Explorer thumbnail cache files (thumbcache_*.db). These caches speed up thumbnail display in folders with images but can grow large over time.

Location

%LOCALAPPDATA%\Microsoft\Windows\Explorer\thumbcache_*

Command
Remove-Item -Force "$env:LOCALAPPDATA\Microsoft\Windows\Explorer\thumbcache_*"

🌐 DNS Cache

Flushes the DNS resolver cache (ipconfig /flushdns). This forces Windows to re-resolve domain names, fixing connectivity issues and clearing outdated entries.

Location

In-memory cache

Command
ipconfig /flushdns

💥 Memory Dumps

Deletes MEMORY.DMP (kernel memory dump) and Minidump files. Created after BSOD crashes and can be very large. Safe to delete after diagnosing crash issues.

Location

%WINDIR%\MEMORY.DMP and %WINDIR%\Minidump\*

Command
Remove-Item -Force "$env:WINDIR\MEMORY.DMP"; Remove-Item -Force "$env:WINDIR\Minidump\*"