Simple scripts to clear temp files, browser cache/history, caches for applications like Microsoft Teams, Slack, Discord, Opera, and OneDrive, and remove Windows Defender scan and definition update backups (including the NisBackup folder), Windows dump files, and Windows Error Reporting (WER) temp files
- Build the graphical installer by running
makensis WindowsClearCache.nsi(or download a pre-builtWindowsClearCacheInstaller.exe).- A GitHub Actions workflow builds the installer and attaches it to a release when you push a tag such as
v1.0.0.
- A GitHub Actions workflow builds the installer and attaches it to a release when you push a tag such as
- Run
WindowsClearCacheInstaller.exeas an administrator.- The installer launches
cleanmgr.exe /sageset:1so you can configure Disk Cleanup before the first run. - You can choose to create a weekly scheduled task that runs the cleanup with highest privileges.
- The cleaner script is copied to
c:\Program Files\WindowsClearCache.
- The installer launches
After installation you can run the cleaner manually with:
powershell.exe -ExecutionPolicy Bypass -File "%ProgramFiles%\WindowsClearCache\DriveClean.ps1"
Optional flags:
- Use
-DryRunto preview the files that would be deleted without removing them. - Use
-Verboseto display each file as it is deleted (or would be deleted in dry run). - Use
-IncludeUsersto target specific active user profiles. - Use
-ExcludeUsersto skip particular user profiles.-IncludeUsersand-ExcludeUsersare mutually exclusive.
- Use
-CleanSystem:$falseto skip clearing system caches. - Use
-CleanUsers:$falseto skip clearing user profile caches.CleanSystemandCleanUserscannot both be set to$false.
Run Uninstall.exe from c:\Program Files\WindowsClearCache or use Add/Remove Programs. This removes the scheduled task and deletes the installed files.
Verified on the following platforms:
| Windows Version | Yes/No? |
|---|---|
| Windows Server 2025 | Yes |
| Windows Server 2022 | Yes |
| Windows Server 2019 | Yes |
| Windows Server 2016 | Yes |
| Windows Server 2012 R2 | Yes |
| Windows Server 2012 | Yes |
| Windows Server 2008 R2 | Yes |
| Windows Server 2008 SP2 | Yes |
| Windows Server 2008 | No |
| Windows Server 2003 | No |
| Windows 11 | Yes |
| Windows 10 | Yes |
| Windows 8 | Yes |
| Windows 7 SP1 | Yes |
| Windows 7 | No |
| Windows Vista | No |
| Windows XP | No |
| Windows 2000 | No |
It is likely to work on other platforms as well. If you try it and find that it works on another platform, please let me know.
- Requires PowerShell 5 or later and administrative privileges.
- Disk Cleanup (
cleanmgr.exe) and DISM may be installed. These tools are present when the Desktop Experience feature is enabled and are not available on Server Core installations, which are required for native Windows optimizations. - The Windows Update service should be available to allow cache cleanup.
WARNING: I do NOT take responsibility for what may happen to your system! Run scripts at your own risk!