Windows and its Temp files

I got a warning this morning that my system drive was down to a couple of GB of free space. This was a little concerning, since it was a 500GB SSD and I stored most of my stuff on a different drive.

Quick check with a few tools, and they also reported that the drive was almost full. I cleared 30+GB using Windows 10’s own Storage settings, and turned off hibernation - but this didn’t account for all the other wasted space. I soon realised the problem - while all of the free space was being reported, most of the files that were wasting space were not.

I now have 322GB free, and can breathe a sigh of relief until Windows goes crazy again.
Switch to running things as Administrator and the problem was easily identified - 283GB of files in \Windows\Temp. Okay - how about I clean out all the temp files prior to today? Hold on - of 57,705 files in the directory, 57,340 were modified today! I asked Windows Explorer to tell me how much space these were taking… 281GB! Windows updated overnight, but this is ridiculous.

I ended up deleting all but the most recent and a couple of old files. Two of the files were locked - no matter. I also looked at a few \temp\ sub-directories that I didn’t think belonged there, and took the opportunity to get rid of them and their contents.

Tip for others who have this problem: Windows tends to hide its innards from you, so you as the ‘dumb user’ don’t mess things up. You need to run either a command prompt (start menu, type cmd) or File Explorer as Administrator by holding the shift key down, right-clicking on the program and selecting “run as Administrator”. Windows 10’s Start Menu search will also display this option on the right of the menu bar if you use it. Be careful with the programs you run as Administrator, as it gives them enormous power.

In my case, Windows correctly reported the used space but it was refusing to tell me what was using most of that space.

6 Likes

Another approach:

As @postulative explained, open Windows Explorer as Administrator.
Navigate to, and right click on the C:\ drive.
On the drop down menu go to Properties (at the bottom)
Stay on the General tab, and go to the Disk Cleanup button below and to the right of the capacity graphic.
It will do some calculations and then present a box called Disk Cleanup for (C:)
Then click on the Clean Up System Files button in the bottom left hand corner
It will do some more calculations and clean up at the same time.
Then Select/tick the boxes of what you want cleaned out. I select everything, but you may wish to keep say User File History or others. Up to you!
Click on OK
It will do some more calculations and clean those things you selected. This step may take some time if you have a lot of space occupied.

Et voila! You have removed the Windows detritis from your disk and lost disk space recovered.

If on a HDD, you should defragment to improve the efficiency of the HDD. [If on a SSD, you don’t need to (and shouldn’t).]

7 Likes

For the recalcitrant user temp files there are some workarounds in Win 7, 8,10

  1. Long process

Create or use another Admin user (you can create another user account from Settings or in Win 7 and 8/8.1 from Control Panel and using the Users menu found there) or use the built in Administrator account (from admin cmd/powershell prompt use net user Administrator /active:yes).

From Control Panel (search for Control and it should appear at the top of the list) then in Win 10 choose the icon called “File Explorer Option” then choose the “view” tab then select to see hidden files and unselect “Hide protected system files (recommended)” (you will get a warning so click “Yes” then click “Apply” or 'Ok".

Sign out of your current user and sign in as either Administrator or the new admin account you created/had.

Clean out the user temp files for the old account (usually found in users/[userprofile name]/appdata/local/temp) & also clean out the temp folder in “Windows/temp”

From the File Explorer Options again choose view and select to Hide protected system files then click “Ok”. You can leave show hidden files enabled or can hide them again if you wish during this step.

Sign out of Administrator or the other account. Relog into the account you normally use and from Admin powershell/Cmd (if you used the built in Administrator account to do the actions use net user Administrator /active:no If you created a new admin user account you can delete the new account (and you can choose to delete all the user files for that account).

  1. Using another program (can be a bit long)

There are several programs that can unlock files that are currently locked. As examples there is Mark Russinovich’s Process Explorer, IOBit’s (free to use) Unlocker, Crystal Rich Ltd’s LockHunter

Steps to follow for IOBit’s and Process Explorer can be read at https://www.howtogeek.com/128680/how-to-delete-move-or-rename-locked-files-in-windows/

  1. Safe Mode of Windows (can take awhile)

Again steps to follow can be read at the howtogeek article https://www.howtogeek.com/128680/how-to-delete-move-or-rename-locked-files-in-windows/

  1. Use a boot stick/disk

Run the installation/recovery disk/stick

Choose the repair option (It is a line on the bottom left, do not Install windows)

Then choose Troubleshoot (this option may not appear and the next one may instead be available already)

Then choose Advanced Options

From the menu that appears choose to run a Command Prompt

From the command prompt move to the appdata folder for the user whose files you wish to clean up…usually found at c:\users[user name you want to clean up]\appdata\local (Type if unsure how to get there cd\ then press enter then type cd c:\users[user name of the one you want to clean]\appdata\local the n press enter) Once at the level type the following rmdir temp /s You may be asked to agree if so press Y. Once it has completed type md temp and press enter. This will create a new Temp folder.

For the Windows temp folder you usually find it at c:\windows and again once in that folder (c:\windows) then type the rmdir temp /s You may be asked to agree if so press Y then after it completes type md temp press enter to complete creating the folder. Restart your machine. If the persistent temp files are created by a startup process you will find they have been recreated, this is normal.

After the removal by whichever method you have chosen to use

Run the Disk cleanup tool or just empty the “Recycle Bin”

If you have an SSD as your drive then run the built in Defrag tool in Windows (type defrag into search and choose the “Defragment and Optimise Drives” app. Select the drive you just cleaned up (most usually C: drive) and click “Optimise” and let it run. Shouldn’t take long to complete.

If it is a non SSD then still use the same program and click the same Optimise button but this may take a much longer time to complete.

3 Likes

Second weekend in a row that Windows has updated and left 300+GB of files behind, along with warnings that I am out of disc space! At least this time I know where to find the damage, and will be complaining loudly to Microsoft about its continued sloppy patching.

According to the last answer in this CNET discussion I am not alone here.

4 Likes