Windows Guides Feed

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
    cleantemp Automatically Delete Temporary Files in Windows 7 [How To]
  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.



 Automatically Delete Temporary Files in Windows 7 [How To]

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 the problems he creates.

Free PC tips by email

Search Windows Guides




Comments

  • Automatically Delete Temporary

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

  • Automatically Delete Temporary

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

  • Pingback: Automatically Delete Temporary Files in Windows 7 [How To … | Windows (7) Affinity

  • muyaad

    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

  • muyaad

    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

  • muyaad

    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

  • muyaad

    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

  • [Guias-Windows] Eliminar autom

    […] Fuente […]

  • [Guias-Windows] Eliminar autom

    […] Fuente […]

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

  • Mel

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

  • Mel

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

  • Mel

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

  • Mel

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

  • Xenio

    Nice tip, I hate temp directory…

  • Xenio

    Nice tip, I hate temp directory…

  • Xenio

    Nice tip, I hate temp directory…

  • Xenio

    Nice tip, I hate temp directory…

  • Kaveesh Dashora

    Nice and Simple Way to Do the Work

  • Kaveesh Dashora

    Nice and Simple Way to Do the Work

  • Kaveesh Dashora

    Nice and Simple Way to Do the Work

  • Kaveesh Dashora

    Nice and Simple Way to Do the Work

  • David Needham

    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.

  • David Needham

    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.

  • David Needham

    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.

  • David Needham

    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.

  • John

    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.

  • John

    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.

  • Rich

    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 :)

  • Rich

    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 :)

  • John

    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.

  • John

    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.

  • Rich

    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 :)

  • Rich

    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 :)

  • Olliehay

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

  • http://mintywhite.com RSVR85

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

  • Dracon

    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?

  • http://richr.org/ Rich

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

  • Dracon

    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?

  • http://richr.org/ Rich

    You got it :)

    The file should like this:

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

  • http://www.Tenbridge.com/ Phil McCusker

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

  • Mononen

    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.

    • Gazman

      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.

      • Binojkr

         good simple clean

      • Binojkr

         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? … “

  • Mclarenf1_fast

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

  • http://www.amenext.com Zubair arif

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

  • Aaa

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

  • Reginacarter76

    remove temporay windows7 sites

  • TSVAMP

    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.


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

Enter your email address:
 

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

Submit Your Tip
Submit your computer tip to us; receive full credit for all published tips

Windows Guides on Facebook