Windows

Forcing Windows XP's Disk Cleanup to delete all temporary files

You may have found that Windows XP's Disk Cleanup utility misses a spot from time to time, retaining temporary files most recently accessed. Here's how to perform a clean sweep of your Windows XP files by forcing Disk Cleanup to get rid of all your temporary files.

If you've ever run the Windows XP's Disk Cleanup utility, you probably discovered that your temporary files occupy a significant amount of space. You might select the Temporary Files check box in order to allow the Disk Cleanup utility to delete the files in the Temp folder, but the Disk Cleanup utility will not remove all of the files. The reason for this oddity is that the configuration for the Disk Cleanup utility does not allow deletion of files accessed in the last seven days.

By altering the LastAccess value in the registry, you can configure the Disk Cleanup utility to delete all the files in the Temp folder regardless of the last accessed date. Here's how:

  1. Launch the Registry Editor (Regedit.exe).
  2. Go to
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\
    Explorer\VolumeCaches\Temporary Files
    .
  3. Locate and double-click the LastAccess value.
  4. When you see the Edit DWORD Value dialog box, change the Value Data setting from 7 to 0 and click OK.
  5. To complete the operation, close the Registry Editor and restart Windows XP.

Changing the value to 0 will force the Disk Cleanup utility to delete all the files in the Temp folder every time that you select the Temporary Files check box.

Notes: Since editing the registry is risky, be sure you have a verified backup before saving any changes. This tip applies to both Windows XP Home and Windows XP Professional.

Miss a tip?

Check out the Windows XP archive, and catch up on our most recent Windows XP tips.

Stay on top of the latest XP tips and tricks with our free Windows XP newsletter, delivered each Thursday. Automatically sign up today!

About

Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.

33 comments
Interested Amateur
Interested Amateur

Here's another clean-up tool. I use "Free Internet Window Washer" to clean out old files including my e-mail folders, multiple browsers, app.s, and Instant Messengers. You can even make your own custom list of files, folders and registry tweaks. I don't know enough to play with the registry so I leave it alone. Go into 'Wash Settings' and click away. I've checked off just about everything and it still takes only a few minutes to run. A great little program and free, too. http://www.eusing.com/Window_Washer/Window_Washer.htm Interested Amateur

DimBulb
DimBulb

The quickest method is to navigate to your TEMP folder, hit CTRL-A, then DEL. This gives you a chance to see what's actually in the folder, and de-select anything you might want to keep. Don't let the computer do all your thinking.

thephpdeveloper
thephpdeveloper

well, i tried the tweak but it seems Disk Cleanup does nothing. The progress bar stops the moment it started. There was no progress for hours. well, i guess i'll use other cleaners instead.

JoeRJr
JoeRJr

Atten: Author and Readers. Be VERY cautious when performing: "force the Disk Cleanup utility to delete all the files in the Temp folder every time that you select the Temporary Files check box." There are quite a few major and minor applications that improperly store critical application settings and/or data IN the TEMP dir. When you clean ALL of the TEMP dir out, some of this applications will cease to work or will not work properly. The fault lies with these applications and their programmers, but the problem nonetheless remains.

dushyant_asp
dushyant_asp

Pleas I want registry for windows you send my maill

RandyM55
RandyM55

I was about to post some of my limited knowledge, but then I noticed the body of this discussion is a year old. "Amateur, Good Luck with Window Washer. Randy

The Admiral
The Admiral

On every machine that I touch, I create a directory called temp. Then change the environment variables to that directory, Internet Explorer Cache into that directory, and any other temporary directorys set up by applications into that directories - like the swap file for Adobe Acrobat, etc then I copied the deltree.exe file from Windows 95 into the Windows Directory in my XP. I then created a batch file that runs and does the following: attrib -h -s -r -a c:\temp\*.* /s deltree /y c:\temp\*.* That gets rid of everything in that directory every time I boot. The tools that Microsoft give you aren't worth beans, since you have to init it and on top of that, it misses half of what needs to be deleted. 90% of the application and network connectivity failures here is because of an overloaded temp directory - believe it or not.

Pedro.V
Pedro.V

I agree that the manual approach is still the best. But here's how you get there fast and easy: click start, then run. Enter '%temp%' (without the '') and hit Ok. This will open the temp folder of the logged on user. PS If you're doing this because you think your office applications might speed up: Log off and log back on again, or it will have no effect.

deepsand
deepsand

Depending on the size the the partition being cleaned, and the type,number, size, and fragmentation of its contents, the analysis step of DC can take a considerable amount of time.

-Falcon-
-Falcon-

I love CCleaner (after disabling its cleaning of Windows Defender) but .... IMHO, Disk Cleaner (http://diskcleaner.nl/) is an even better application than CCleaner. It is also freeware but has a smaller footprint and is faster than CCleaner. Give it a try!

vince.ros
vince.ros

Yes, I fully agree with you. Actually I never clean up Temp folders by using automatic tools, but I do it manually carefully selecting what I delete. Since disk space is not too much of a problem today, I prefer to maintain more files than strictly needed rather than take the chance of deleting necessary files.

jpdecesare
jpdecesare

That's true about mandatory files in the temp directory. However, whether you leave the value at 7 or change it to 0 won't matter, because the mandatory files will get wiped eventually, either now or in 7 days. Assuming there aren't any mandatory files in Temp, then this is a great hack. As a developer (MCSD), the notion of permanent files intentionally stored in the Temp folder is absurd (especially in commercial software), but folks do it for some reason.

deepsand
deepsand

The Registry Hive is not a separate application, but is an integral part of the Windows OS.

croman.pr
croman.pr

I'm a Vista user and do my research in the Vista registry and found the same registry value exists in the registry. You can safely change the values (7) to any (0) to force deleting the temporary files. However, I set it to (1) since I found during time that there are temporary files that windows use at some time and cannot be deleted.

michaellashinsky
michaellashinsky

I also manually delete the temp files. There are temp folders in every user's profile, and they can be stupidly large. IE by default sets the user's cached files at something absurd, like 587 MB, or (some odd and large number over 500 MB.) I try to delete the temp files within IE for each user, (but only if I am privileged to their password because you have to be logged on as each one to empty each one the right way.) Then I empty the "C:\Documents and Settings\*user*\Local Settings\Temp\" folder for each user. Then defrag and check disk. This is all after I have installed updates and/or software. On my home PC I can delete another gig and a half of redundant files, but that is another thread. If you are interested, google and article named "slimming down windows XP". I learned a lot from it.

deepsand
deepsand

Where possible, I create a small partion just for temp files. Thus, not only are they quickly and easily accessible, they've no effect on the fragmentation of the rest of the physical drive.

dbreuer
dbreuer

I've created a similar batch file that runs and does the following: del %temp%\?*.* /a-a /s >nul attrib -a %temp%\?*.* /s This only gets rid of everything that has been there trough one boot, just in case.

thephpdeveloper
thephpdeveloper

it took me hours using DC, i'd rather use CCleaner which takes up less than a minute.

CharlieSpencer
CharlieSpencer

I've seen it firewall a cpu over a weekend and never put a block on the progress bar.

HelpDeskGuy
HelpDeskGuy

All depends....yes, maybe smaller and faster, but for my purposes, CCleaner cleans and you can select what to clean as with Disk Cleaner, but CCleaner also has a startup manager, application uninstall manager, issue scanning and the ability to select what cookies to keep or delete. So I get all those tools in one app for free...one stop shopping. So I'll deal with the overhead and slower speed for all that.

AndyW360
AndyW360

I also recommend CCleaner, a great little application for cleaning Windows temporary files and it's free !

jdclyde
jdclyde

Anything from ZoneAlarm to a print monitor, has active files in the temp folder. When you go to manually clear the directory, it will not ALLOW you to delete the files in use. I have always found it best to do a REBOOT after clearing the temp folder. This way, if there WAS a TEMP file in the TEMP folder that was needed, it will be put back when you reboot and relaunch the application.

Rob Kuhn
Rob Kuhn

Are your users part of Active Directory? If so, have your considered using the login scripts to help standardize the TEMP locations? I also believe there is a registry hack where you can set the "environment" settings to be the same amongst all local users including new users. But you're right. If you have a machine where there are more than one user on it you can have multiple TEMP locations just eating up space.

deepsand
deepsand

The only times that I've seen it consistently respond with reasonable alacrity is when I've moved the Swap file to its own dedicated partion.

ron.dondelinger
ron.dondelinger

Been using CCleaner for years. This utility is darn near idiot-proof, and I have educated many a tech-ignorant user on how to conduct the basic disk cleaning steps, should they prefer to run it manually vs. the automatic scheduled runs.

thephpdeveloper
thephpdeveloper

i agree with that you think. If you compare the cleaning time for CCleaner and Disk Cleanup, you'll see the large difference between them

huoml
huoml

but ccleaner also has a setting that by default (at least on my install) will only delete files that are more than 48 hours old. but as others have said, when deleting files, I try not to do anything AUTOMATIC.

gboyce
gboyce

I couldn't agree more. CCleaner is a great app! It's free, efficient, and really works. I recommend it highly. Here's the link: http://www.ccleaner.com/ Take care, George Boyce Owner GB Plus PC Repair www.gbpluspcrepair.com

deepsand
deepsand

there is no universal script of the sort that you seek.

todd
todd

Where can I find these logon scripts that will clean all temp files from all users?

Editor's Picks