Web Analytics


The Windows Disk Cleanup Wizard will delete your temporary files, but only if they are over a week old. To create a simple batch script that will clean up your temporary directories, do the following (Vista instructions):

Creating the Batch File to Clean Temporary Files

  1. Open Notepad and type the following:

    cd C:\Users\%username%\AppData\Local
    rmdir /S /Q Temp

  2. Save the file as cleantemp.bat
    Automatically delete temporary files in Windows 7
  3. Now double click on the file to remove your temporary files and free up space on your computer

If this doesn’t work and gives an access error, try replacing %username% with you windows login username.

Automating the Process of Deleting Temporary Files

To automate this process, so you do not need to remember to run it, do the following:

  1. Right click on the batch file and select create shortcut
  2. Place the shortcut in your startup folder in the start menu

Now when you log in to Windows 7, your temporary files will be deleted.

About Rich

Rich is the owner and creator of Windows Guides; he spends his time breaking things on his PC so he can write how-to guides to fix them.

Free PC tips by email

Search Windows Guides




Comments

51 thoughts on “Automatically Delete Temporary Files in Windows 7 [How To]”

  1. Automatically Delete Temporary says:

    […] Here is the original post: Automatically Delete Temporary Files in Windows 7 [How To #8230 […]

  2. Automatically Delete Temporary says:

    […] Here is the original post: Automatically Delete Temporary Files in Windows 7 [How To #8230 […]

  3. Pingback: Automatically Delete Temporary Files in Windows 7 [How To … | Windows (7) Affinity
  4. muyaad says:

    i did it many time, all what i got was a black flashed command-line windows that quickly went off without emptying my Temp folder

  5. muyaad says:

    i did it many time, all what i got was a black flashed command-line windows that quickly went off without emptying my Temp folder

  6. muyaad says:

    i did it many time, all what i got was a black flashed command-line windows that quickly went off without emptying my Temp folder

    1. manoj kumar says:

      great article , I really like it

  7. muyaad says:

    i did it many time, all what i got was a black flashed command-line windows that quickly went off without emptying my Temp folder

  8. [Guias-Windows] Eliminar autom says:

    […] Fuente […]

  9. [Guias-Windows] Eliminar autom says:

    […] Fuente […]

  10. Pingback: [Guias-Windows] Eliminar automáticamente los archivos temporales de Windows 7. | subinet.es beta información tecnológica y de actualidad.
  11. Mel says:

    I don’t know that I’d be pressed for space enough to want to do this…

  12. Mel says:

    I don’t know that I’d be pressed for space enough to want to do this…

  13. Mel says:

    I don’t know that I’d be pressed for space enough to want to do this…

  14. Mel says:

    I don’t know that I’d be pressed for space enough to want to do this…

  15. Xenio says:

    Nice tip, I hate temp directory…

  16. Xenio says:

    Nice tip, I hate temp directory…

  17. Xenio says:

    Nice tip, I hate temp directory…

  18. Xenio says:

    Nice tip, I hate temp directory…

  19. Kaveesh Dashora says:

    Nice and Simple Way to Do the Work

  20. Kaveesh Dashora says:

    Nice and Simple Way to Do the Work

  21. Kaveesh Dashora says:

    Nice and Simple Way to Do the Work

  22. Kaveesh Dashora says:

    Nice and Simple Way to Do the Work

  23. David Needham says:

    Hmmm, I’ve been using “cleanmgr /sagerun:99” for a while to do something similar by running the Windows Cleanup tool (A Good Thing: run “cleanmgr /sageset:99” to set options before running “cleanmgr /sagerun:99”). Works as well in the startup folder for “automagic” invocation at startup.

  24. David Needham says:

    Hmmm, I’ve been using “cleanmgr /sagerun:99” for a while to do something similar by running the Windows Cleanup tool (A Good Thing: run “cleanmgr /sageset:99” to set options before running “cleanmgr /sagerun:99”). Works as well in the startup folder for “automagic” invocation at startup.

  25. David Needham says:

    Hmmm, I’ve been using “cleanmgr /sagerun:99” for a while to do something similar by running the Windows Cleanup tool (A Good Thing: run “cleanmgr /sageset:99” to set options before running “cleanmgr /sagerun:99”). Works as well in the startup folder for “automagic” invocation at startup.

  26. David Needham says:

    Hmmm, I’ve been using “cleanmgr /sagerun:99” for a while to do something similar by running the Windows Cleanup tool (A Good Thing: run “cleanmgr /sageset:99” to set options before running “cleanmgr /sagerun:99”). Works as well in the startup folder for “automagic” invocation at startup.

  27. John says:

    First off Rich, I really don’t like this new way of leaving a comment. The reason I registered here on this site is because I value my privacy and not sharing my info with others but only with those “I” chose. All I needed to do before was login and I could make a comment but now I had to do this through my Yahoo account and that just sucks. The only reason I’m continuing this conversation, is that I wish to make my point on this subject and I also had a question concerning this topic and was hoping to be entered for the Windows 7 Ultimate contest,lol. Anyways Mate, I’m very sorry for sounding very angry but enough of our personal info. is out there as it is and I only wished to deal with this site,you and our membership. This has been an excellent and very informative site for someone,as myself, whom may not be very “UP” when it comes to computers. If there is another way of posting,besides this way,the old way or a way that I don’t know about, I would like to continue using your excellent site Rich. If not, I’ll not be using this site anymore,very regretably, and wish to thank you and everyone else here for all their excellent work that has helped me along with my computer so far. If there is no other way of posting that’s only through this site,like the old way, then please delete me from any further e-mails please. Thank You. Yours sincerely GOLDENBOYWPG.

  28. John says:

    First off Rich, I really don’t like this new way of leaving a comment. The reason I registered here on this site is because I value my privacy and not sharing my info with others but only with those “I” chose. All I needed to do before was login and I could make a comment but now I had to do this through my Yahoo account and that just sucks. The only reason I’m continuing this conversation, is that I wish to make my point on this subject and I also had a question concerning this topic and was hoping to be entered for the Windows 7 Ultimate contest,lol. Anyways Mate, I’m very sorry for sounding very angry but enough of our personal info. is out there as it is and I only wished to deal with this site,you and our membership. This has been an excellent and very informative site for someone,as myself, whom may not be very “UP” when it comes to computers. If there is another way of posting,besides this way,the old way or a way that I don’t know about, I would like to continue using your excellent site Rich. If not, I’ll not be using this site anymore,very regretably, and wish to thank you and everyone else here for all their excellent work that has helped me along with my computer so far. If there is no other way of posting that’s only through this site,like the old way, then please delete me from any further e-mails please. Thank You. Yours sincerely GOLDENBOYWPG.

  29. Rich says:

    John,
    If I understand correctly, you want to be able to comment without your Yahoo account? You can sign up for a JS-Kit.com account with the username GOLDENBOYWPG and you’ll be as anonymous as ever before.

    Hope that helps :)

  30. Rich says:

    John,
    If I understand correctly, you want to be able to comment without your Yahoo account? You can sign up for a JS-Kit.com account with the username GOLDENBOYWPG and you’ll be as anonymous as ever before.

    Hope that helps :)

  31. John says:

    First off Rich, I really don’t like this new way of leaving a comment. The reason I registered here on this site is because I value my privacy and not sharing my info with others but only with those “I” chose. All I needed to do before was login and I could make a comment but now I had to do this through my Yahoo account and that just sucks. The only reason I’m continuing this conversation, is that I wish to make my point on this subject and I also had a question concerning this topic and was hoping to be entered for the Windows 7 Ultimate contest,lol. Anyways Mate, I’m very sorry for sounding very angry but enough of our personal info. is out there as it is and I only wished to deal with this site,you and our membership. This has been an excellent and very informative site for someone,as myself, whom may not be very “UP” when it comes to computers. If there is another way of posting,besides this way,the old way or a way that I don’t know about, I would like to continue using your excellent site Rich. If not, I’ll not be using this site anymore,very regretably, and wish to thank you and everyone else here for all their excellent work that has helped me along with my computer so far. If there is no other way of posting that’s only through this site,like the old way, then please delete me from any further e-mails please. Thank You. Yours sincerely GOLDENBOYWPG.

  32. John says:

    First off Rich, I really don’t like this new way of leaving a comment. The reason I registered here on this site is because I value my privacy and not sharing my info with others but only with those “I” chose. All I needed to do before was login and I could make a comment but now I had to do this through my Yahoo account and that just sucks. The only reason I’m continuing this conversation, is that I wish to make my point on this subject and I also had a question concerning this topic and was hoping to be entered for the Windows 7 Ultimate contest,lol. Anyways Mate, I’m very sorry for sounding very angry but enough of our personal info. is out there as it is and I only wished to deal with this site,you and our membership. This has been an excellent and very informative site for someone,as myself, whom may not be very “UP” when it comes to computers. If there is another way of posting,besides this way,the old way or a way that I don’t know about, I would like to continue using your excellent site Rich. If not, I’ll not be using this site anymore,very regretably, and wish to thank you and everyone else here for all their excellent work that has helped me along with my computer so far. If there is no other way of posting that’s only through this site,like the old way, then please delete me from any further e-mails please. Thank You. Yours sincerely GOLDENBOYWPG.

  33. Rich says:

    John,
    If I understand correctly, you want to be able to comment without your Yahoo account? You can sign up for a JS-Kit.com account with the username GOLDENBOYWPG and you’ll be as anonymous as ever before.

    Hope that helps :)

  34. Rich says:

    John,
    If I understand correctly, you want to be able to comment without your Yahoo account? You can sign up for a JS-Kit.com account with the username GOLDENBOYWPG and you’ll be as anonymous as ever before.

    Hope that helps :)

  35. Olliehay says:

    How can I tell if it actually did anything? My free disk space didn't change.

  36. RSVR85 says:

    In Explorer, navigate to C:Users%username%AppDataLocal
    If there is a Temp folder in this location, the clean has been unsuccessful.

  37. Dracon says:

    I have a shortcut to clear the RAM; here;s the target of the shortcut: “%windir%system32rundll32.exe advapi32.dll,ProcessIdleTasks”. I was wondering if there is a way to add this to the .bat?

  38. Rich says:

    You can add that in but I don't recommend using this command. If your system needs memory, it will automatically do this anyway.

  39. Dracon says:

    Thanks for the response. If I were to add this in, do I just paste the target in on the line after rmdir /S /Q Temp?

  40. Rich says:

    You got it :)

    The file should like this:

    cd C:Users%username%AppDataLocal
    rmdir /S /Q Temp
    %windir%system32rundll32.exe advapi32.dll,ProcessIdleTasks

  41. Phil McCusker says:

    My temp directory is f*****g 25gigs..

  42. Mononen says:

    Hm..this method removes the Temp folder, and some programs need it to work. Folder Lock for instance. Could someone make a batch file that empties %UserProfile%AppDataLocalTemp and %SystemRoot%Temp but doesn´t remove the folders..? On vista and xp this “add clear system temps” thing http://www.vistax64.com/tutorials/74471-recycle-bin-add-program-menu.html works like a charm, but a batch file for windows 7 would rock. Thanks.

    1. Gazman says:

      A simple batch file for Windows 7 to clear the temp folder contents at
       %UserProfile%AppDataLocalTemp would be:

      cd %tmp%
      rd /s/Q .

      (that’s cd space %tmp% and then on second line rd space /s/Q space dot.

      The same method can be used for the system temp folder at %SystemRoot%Temp
      To automate simply place the batch file in your startup folder at:

      C > Users > Name > AppData > Roaming > Microsoft > Windows > Start Menu > Programs > Startup

      This will delete the contents of the temp folder at every boot but leave the actual directories (Temp Folders) intact.

      1. Binojkr says:

         good simple clean

      2. Binojkr says:

         One problem though.
        This clears the temp even when you reboot after a crash. That way temp files created by programs like AutoCAD would be cleared and hence the ‘last chance’ to recover the drawing would be lost. Could you add one more line to take the user input Y/N with a question “About to Clear Temp Folder.  Proceed? … “

  43. Mclarenf1_fast says:

    On the start menu search bar just type in `%temp%` (without quotations) and the temporary folder should open. Hit `Ctrl A`and delete.. :-)

  44. Zubair arif says:

    1-navigate to C:UsersAdministratorAppDataLocalTemp DEL ALL
    2-C:WindowsTemp DEL ALL
    3-C:WindowsPrefetch DEL ALL

  45. Aaa says:

    cool! works reat on WIN7 – ty a lot :)
     

  46. Reginacarter76 says:

    remove temporay windows7 sites

  47. TSVAMP says:

    Sure all you have to do is this

    cd %temp%
    del *.* /F /Q
    RD /S /Q %temp%

    cd C:WindowsTemp
    del *.* /F /Q
    RD /S /Q %temp%
    This will remove all non used directories and remove all temp files out of the temp and windows temp folders.   Any other folder you want to clean out you just replace the first line with the directory you want cleared.

Comments are closed.


Computer tips in your inbox
Sign up for the Windows Guides newsletter to get PC tips and access to free Windows books (More details)

Subscribe now
Popular Guides

See which sites have been visited on your PC (even if private browsing mode is used)

Create a Windows 7 System Repair Disc

Best Free Anti-malware

Hibernate vs. Sleep vs. Shut-Down

i3, i5, and i7; Dual, Quad, Hexa Core Processors. How to they Differ?

Intel's Ivy Bridge Processor: new Features

Windows Guides on Facebook