Disk Cleanup (Cleanmgr.exe) is a built-in tool in Windows which offers some useful cleanup options not available in other 3rd party cleanup tools. It can remove superseded device drivers, Temporary Files, Internet Explorer cache, obsolete Windows Updates, Previous Windows Installation (Windows.old) folder, and much more.
But you may be wondering why Disk Cleanup skips deleting some files and folders in your TEMP folder.
Why Does Disk Cleanup Leave Behind Temp Files?
When it comes to deleting Temporary Files, Disk Cleanup by default doesn’t wipe out items that match the following criteria:
- Files with Read-Only, System or Hidden attributes
- Files which have been accessed in the last seven days
- Directories that have been created in the last seven days.
For criteria 2: With a simple registry edit, you can make Disk Cleanup erase all Temporary Files or only the files whose last accessed timestamp is greater than “n” number of days from the current date.
Make Disk Cleanup erase all the Temporary files
Start the Registry Editor and go to:
In the right-pane, double-click LastAccess.
Set the value data for LastAccess to 0.
“LastAcess” value represents the number of days that must have elapsed since a file was last accessed or a directory was created for that file or directory to be considered for cleanup by Cleanmgr.exe.
By setting the LastAccess registry value data to 0, you can force Disk Cleanup to clean up all the Temporary Files. It skips files that can’t be deleted — such as files that are currently in use by applications, and the ones you don’t have write access.
To be on the safer side, you may set “LastAccess” to “3” so that Disk Cleanup doesn’t erase the files that have been used in the last three days. “3” is safer because just in case some currently running application has stored the temporary data over there, and you’ve been hibernating the system (instead of shutting it down daily) a lot, lately.
The above is the same registry edit that I wrote about in 2005. It applies to Windows 2000/XP through Windows 10. Ref: Alter the “LastAccess” value for cleaning the Temporary files using Disk Cleanup utility.
Running Disk Cleanup with the default “LastAccess” value left lots of files and folders untouched.
Only the folders created (and files accessed) before Oct-25 were cleared — clean up done today, Nov-1.
After applying the registry setting, I reran Disk Cleanup.
The temporary files are all gone, except the in-use files and folders.
Temporary files Locations
As a side note, if you clean up Temporary Files when Disk Cleanup is running elevated (“Run as Administrator”), “temporary” files in the following folders and sub-folders are cleared as well, in addition to files and folders in the user’s TEMP directory.
One small request: If you liked this post, please share this?One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
- Pin it!
- Share it to your favorite blog + Facebook, Reddit
- Tweet it!