Deleting temporary files on Windows 10.
Junk files are unnecessary, or unused files that gather over time, reducing the free space available on your local disk, and potentially reducing system performance and increasing errors. Junk files also increase the risk of malware. Temporary files are created by Windows and application programs to store information temporarily. A majority of them finishes by becoming junk, even though not all temporary files may be considered to be junk files. Anyway, deleting temporary files should be regularly done in order to assure that your computer runs smoothly.
Windows 10, as the Windows releases before, includes a utility called Disk Cleanup. To start it, open Windows File Explorer with the disk drives displayed. Right-click the Windows drive (drive C), and from the opening context menu, choose Properties, then in the Properties window, push the Disk Cleanup button. To include no more needed system files (as for examples the downloads from Windows Update), click the Clean up system files button. The Disk Cleanup window shows how many space is occupied by various types of files (Recycle Bin files, temporary files, thumbnails, etc). As you can below, there were more than 16 GB of temporary files on my computer, when I took this screenshot.
Pushing the OK button starts the cleanup process. However, no idea why, Windows 10 Disk Cleanup actually does not delete the temporary files!
The latest Windows releases include a feature called Storage Sense. You can access it by choosing Settings > System > Storage. On its main page, a summary of the used space on the Windows disk is displayed. More than 25 GB of temporary files in my case!
The link Configure Storage Sense or run it now leads to a second page. Here you can select what Storage Sense should clean (there is a checkbox for cleaning temporary files), and when to do it. By default, it's only done during low free disk space; you can however choose to run it every month, week or even day. You have also the possibility to run it manually. That's what I did, with the result that the size of my temporary files diminished to some 9 GB (the size of the files deleted corresponding to the 16 GB indicated as "total amount of disk space you gain" in Disk Cleanup).
Still 9 GB of temporary files there, however. Before deleting them all manually in Command Prompt, lets have a look at TreeSize Free, an application to quickly scan directory sizes and find space hogs. You can download the tool from the JAM Software website. To start the scan, choose Select Directory from the menu bar and choose your Windows drive from the drop-down list. A dialog pops up informing you that to scan all folders, you'll need admin privileges. Choosing Always start as administrator will add a "TreeSize Free (Administrator)" launcher to the Start menu (maybe that it was already there before, but that I didn't notice it...).
The application shows the folder structure of the selected directory (drive C: in our case), indicating how much space is taken by each directory and in the different directories by each subdirectory and each file. Note that the directory tree includes hidden, and also system files and folders.
Windows temporary files are located in C:\Windows\Temp and opening this folder in TreeSize shows these files, that use 9.6 GB of space on my disk. The screenshot below shows the local temporary files folder located somewhere in the user's AppData folder (the exact path is stored in the environment variable %temp%). In my case, there are less than 250 MB. We will free this space anyway (cf. further down in the text).
The (probably) simplest way to get rid of the temporary files is to use the del command in Command Prompt. Do not run Command Prompt by double-click, but instead right-click the launcher, and from the opening context menu choose Run as administrator. This will give you access to those files that otherwise you couldn't delete.
Here are the commands to delete the Windows temporary files:
cd \Windows\Temp
del /s /f /q *.*
and here those to delete the user's temporary files:
cd %temp%
del /s /f /q *.*
Meaning of the switches: /s = include subdirectories, /f = force delete of read-only files, /q = quite mode.
The screenshots show a part of the output of the delete operation. Note, that the files actually in use cannot be deleted.
If Storage Sense hasn't deleted all files, does that mean that it could be unsafe to do it manually, you may ask. I think that all experts would tell you that yes, it is safe. Deleting a temporary file does not delete a file that is part of the system or an application; so neither Windows, nor an application or its data will be affected by the deletion. Files that are actually in use are locked, you can't delete them, so you will not have to be scared that some actually running application might crash. And if a temporary file could perhaps be used by an application started later, it will simply be recreated...
If you find this text helpful, please, support me and this website by signing my guestbook.