Windows 10 got the ability to clear temporary files automatically in a recent build. Starting with build 15014, a new option appeared in Settings. Here is how you can use it.
To clear temporary files automatically in Windows 10, you need to enable the new option. Open Settings and go to System -> Storage. There, you will find the option named "Storage Sense". Enable it and you are done.
But the built-in auto cleanup feature is new to Creators Update. Files stored in Recycle Bin for more than 30 days will be deleted for example as part of this cleanup.
There, you'll see two options. One is Delete temporary files that my apps aren't using.
It is a good idea to keep this turned on. Temporary files are created by various Windows services, installed apps and tools. Temporary files can be safely deleted after the process which has created them has quit. However, this does not happen often, so the system temporary directory or the app's temp directory continues to store them and fills your disk drive with junk. When this option is enabled, Windows will delete them automatically and keep you drive clean besides saving your disk space.
If you do not have Windows 10 Creators Update installed yet, it is not a problem. Windows ships with a tool to clean up files called Disk Cleanup. It can be automated using Task Scheduler or by simply creating special shortcuts to cleanmgr.exe with various switches. We have covered this extensively at Winaero.
There are two ways to clean up your temp directory automatically, which can be used in previous releases of Windows 10 too. Check out these articles:
- Clear Temp Directory on Startup with Disk Cleanup. It explains to clean up the temp directory automatically in Windows 10 using the built-in Disk Cleanup tool (cleanmgr.exe).
- Clean up temp directory automatically in Windows 10. It shows how to clean up temporary files with a simple batch file which cleans your Temp folder every time you start your PC.
The other option is Delete files that have been in the recycle bin for over 30 days. As is obvious from its name, it will clear your Recycle Bin automatically, so deleted files won't grow in size. This is very useful.
If you are running a Windows 10 version without this feature, you still empty Recycle Bin automatically. The following article describes the process:
Using the instructions in that article, you will be able to create a Scheduled Task which calls a special PowerShell command to clean up the Recycle Bin. It is a nice alternative to this new feature.
The native ability to remove temporary files automatically is one of the best improvements to the built-in maintenance tools in Windows 10. Once you enable this feature, you can finally forget about the existence of the temp folder and its contents.
We hope Microsoft extends this to clean up Windows Update related files too in the future such as files superseded by newer versions and downloaded updates in the Software Distribution folder.