• ARTICLES
SEARCH

How-To Geek

Why Doesn’t Disk Cleanup Delete Everything from the Temp Folder?

sshot-2010-12-02-1-01-25-06

After you’ve used Disk Cleanup, you probably expect every temporary file to be completely deleted, but that’s not actually the case. Files are only deleted if they are older than 7 days old, but you can tweak that number to something else.

This is one of those tutorials that we’re showing you for the purpose of explaining how something works, but we’re not necessarily recommending that you implement it unless you really understand what’s going on. Keep reading for more.

Why Doesn’t Disk Cleanup Delete All Files?

The applications that you’re running create temporary files, not to litter your hard drive, but to store files while the application is working on them—whether it’s downloading files, storing files that you’re currently editing, or just caching files so the next time you open the application the files will be more quickly accessible.

The problem is that most applications don’t seem to clean up after themselves, or if they do, they definitely don’t do it very well. That’s why your temporary folder gets really huge over time, and needs to be cleaned out.

Since these files are often being used by applications, Windows doesn’t know whether a particular file can be deleted, so Disk Cleanup only cleans up files that are older than 7 days, which is a safe guess—most people probably don’t have an application open for more than a week, especially since Microsoft makes you reboot nearly every Tuesday, right?

image

You can even see in the screenshot that Disk Cleanup explains this to you, if you select the Temporary files option in the list.

Change Disk Cleanup to Delete Files Newer than 7 Days

If you’re one of those people that reboots your PC every day, you can probably change the Disk Cleanup value down to something lower, like 2 days. If you don’t reboot but you rarely keep applications open, you could probably do fine with 2-3 days instead, though the value you choose is really up to you—just keep in mind applications need those temporary files if they are running.

Open up regedit.exe through the Start Menu search or run box, and then browse down to the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
   CurrentVersion\Explorer\VolumeCaches\Temporary Files

Once you’re there, you’ll see the LastAccess value on the right-hand side, which contains a value that specifies the number of days, which you can change to whatever you’d like.

image

If you want to see the results of your changes, you can open up your temporary folder by entering the following into the Windows Explorer location bar:

%temp%

image

And again, if you’re an average user, you probably shouldn’t mess with this registry value—but at least you know a little more how it works, right?

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 12/2/10

Comments (23)

  1. David Crowley

    Just go run “%temp%” and delete all the files there every once in a while! or use CCleaner

  2. rOckY

    Ditto on CCleaner – way easier to use and highly effective.

  3. jayjoe

    I use CCleaner too, very easy and good tool

  4. BigJohn

    I concur.
    Just run CCleaner once a week and forget all the tech crap.

  5. raphoenix

    Configure CCleaner to run at every machine startup.
    OR
    Run CCleaner and Disk Cleanup Before shutting down machine daily.

  6. Oaken

    Very helpful for me, thanks.

    Agree with raphoenix, it will be better to set any schedule to the times suggested.

    I use CCleaner, though have recently been testing Bleachbit (portable) which seems to reveal a good deal more temporary files?

    Food for thought…

  7. HCamper

    @David Crowley
    I agree CCleaner is good but even it can make mistakes.

    You have to be very careful in using “Wildcards” like *.* in the temp folders.
    In the user “”/App/data/temp” or “\Windows\Temp\
    some installers are assuming the files in temp folder are untouchable.
    Good example of this are HP installers you can destroy the data required
    for “HP Advisor” and “PC Restore”
    if your not very careful.
    To verify what not to delete in temp folders check the “HKLM” uninstall
    branch of registry.
    You often will find a hard link to a msi installer or setup.exe.
    One solution is to move the files to some other location and re-link location in registry and only then you can delete the temp file location.
    Check the “HKLM” current control session value you may find
    a pending file rename is pointing to temp folder.
    If there is a value wait until after reboot before removing temp files
    or you may find last install
    will have a bogus time stamp for install date. Good example are some of “Null Soft” installers
    will show wrong dates if file rename is not successful.

    Martin :-)
    Windows and Linux can Work Together

  8. Chronno S. Trigger

    @BigJohn

    But this is How To Geek. You wouldn’t be vary geek if you didn’t know how to do this manually.

    Anyone else notice that disk cleanup is gone from Server 2008? Or did it just move?

  9. MarkieMark

    I use Temp File Cleaner 3.0.4 which REALLY cleanes everything – great prog!

  10. Justin

    Is it safe to goto the %temp% folder and just delete everything?

  11. HCamper

    @Justin the simple answer is no it is not “Safe”.
    The alias %temp% points to C:\User\App\local\Data\Temp removing
    all files from this set of folders can cause many problems.
    You may find if you clear all the
    *.tmp or *.temp from %TEMP% in Windows 7 your taskbar may go away
    and not return until a logoff.
    You have to be very careful in using “Wildcards” like *.* in the temp folders.
    I hope this helps
    Martin
    Windows and Linux Can Work Together
    :-)

  12. Jon

    Just format the entire hard drive and install Linux Mint. Problem solved.

  13. Taurus_G4

    when there are tools like atf cleaner or ccleaner who require these things :p

  14. julia

    I like a clean machine,I clean and defrag..ever day.However one night after fun and a few beers I deleted my total O.S.no joke this was funny.Be careful with disk cleanup.Bye.

  15. Stew

    @julia- Unlikely

  16. philip varghese

    %temp% is the better way.

  17. skulldrinker

    I wrote a batch file to delete all the files + allz I have to do is click on it when needed. Also Easy Cleaner comes in handy.

  18. HCamper

    @Jon
    I guess you have never have had to deal with a dedicated Linux Server system.
    Linux Systems and Users are no less messy than Windows when leaving behind junk or bad files!
    I have had to clean up Linux machines used for Web Hosting Server,Windows Logon Profile server and Database Server. I could never just suggest reformat the system to solve any problems. On average it would take a full day to back-up,move and clean a Linux Hosting Server.
    The littering of dead temp files,useless links and left over profiles makes Windows trash look trival.
    It would have ben nice to have a GUI tool like CCleaner to help.
    When I first started doing clean-up everything had to be created from hand made shell scripts.
    Now with things like “Bleachbit” for Linux life is so much easier.
    So just a reformat with new OS is not a really good answer for either home or business user.

    Martin Rasch :-)
    Windows and Linux can Work Together

  19. Jon

    @HCamper
    I’m not talking about Linux servers. I’m talking about Linux desktops. If you want to talk about servers then we can talk about Microsoft SQL Server, which doesn’t have any convenient Disk Cleanup utility to purge all the massive log and temp files caused by massive batch jobs and queries. I’ll never forget one server had a 120GB temp file. How you make a temp file that big? I have no idea.

  20. Lukong

    Cleaner all the WAY…THREE CHEERS FOR GEEKSTARS & CCLEANER

  21. oldtima

    or use this cmd trick from xp’s days,

    %SystemRoot%\System32\Cmd.exe /c Cleanmgr /sageset:65535 & Cleanmgr /sagerun:65535

    adds a lot more options to clear , and works well in 64b windows 7

  22. dixie_mom

    I agree with HCamper
    @David Crowley
    I agree CCleaner is good but even it can make mistakes.

    Good example of this are HP installers you can destroy the data required
    for “HP Advisor” and “PC Restore”
    if your not very careful.

    I used CCleaner and noe both my HP Advisor and PC Restore are missing and i do not know how to get them back,, Any suggestions?

  23. RacerMaster

    @dixie_mom
    I have an HP as well. You can reinstall HP Advisor from
    http://h71028.www7.hp.com/hho/cache/456501-0-0-225-121.html
    Not sure about PC Restore, though.

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!