Delete your TEMP files on shutdown

It is really easy to set Windows XP to delete the contents of your Temp folder (or run any other commands) on shutdown. There are numerous reasons why you might want to delete your Temporary files when you shutdown Windows XP. Your Temporary files folder can get extremely large. Take a look at what’s in C:\WINDOWS\Temp.

The first step is to install Xecutor. You can download Xecutor from the Xpertdesign homepage.

The second step is to create a batch file that will delete your temporary files on shutdown. To do this open up notepad and type the following line:
del /Q G:\WINDOWS\Temp save your file as tempdelete.bat. Alternatively, you can download my tempdelete.bat file if you prefer.

The third step is to configure Xecutor to run the tempdelete.bat file on shutdown. Open Xecutor, and answer no to the stream of questions
it prompts you with the first time you run it. Next choose the shutdown tab and add tempdelete.bat file. This is shown below:
Shutdown image

After you hit OK you will now see tempdelete.bat in the shutdown tab of Xecutor. This is shown below:
Shutdown image 1

Now just close Xecutor and it will run in your system tray. The last step is to drag the Xecutor icon from your desktop into your Startup folder located in Start >> All Programs >> Startup so that Xecutor starts when you start Windows. This is shown below:
Shutdown image 2

You are all set, now when you shutdown Windows, your temporary files will be deleted, as well. You can add other commands the same way (i.e., delete cookies, delete My Documents, etc.).

What other commands do you think would be useful to run at Shutdown? Let us know in the comments.

Trackbacks & Pings

Comments

  1. Sorry if this is a stupid question… but why do you use G:\ in the batch file? Is there a specific reason for using G? or is it just computer specific, i.e. using the actual drive?

  2. @Jimmy: My local hard drive is G instead of C. I set this up to avoid poorly written viruses and spyware that are hard coded to attack the C drive.

    I wish there was an actual way that I could teach users how to do this, but I just had a jump drive plugged into my USB when I installed Windows. So my local drive got named G and my external drive is C.

  3. If you want to delete your temp-files I would delete files in %USERPROFILE%\Local Settings\Temp, since that’s were they are..

  4. Word of caution. Some installers when they have finished and require a reboot, continue the installation afterwards.

    Have a guess where their files to continue get stored “temporarily”?

    I agree that clearing out “temp” is a worthwhile job, seeing as it gets filled with so much garbage, but I don’t think automating it is such a good idea.

  5. Great post, i currently use ccleaner to remove temp files, registry entries etc. Does anyone know where i can download pre made batch files that will remove similar items?

    Thanks

  6. I was attempting to create this batch file for the %USERPROFILE%\Temp folder, but it’s not working. I had success with the Window’s Temp folder. Could the spaces in the folder names be throwing DOS a curve? If so is there a way around it?

  7. @Ryan: Yes, spaces will throw off the batch file. All you need to do is put your directory name in quotes. For example My Favorites would have to be “My Favorites.”

  8. I’m having trouble with xecutor–the help pages are all in German and I can’t figure out how to change the settings. Can anyone help me?

  9. @EV Harper: Sure. What would you like to change?

  10. If you’re using linux, check out this: http://tech.karbassi.com/2007/01/14/remove-temp-folder-contents-on-shutdown/

  11. Hello! Interesting and excellent site with interesting design.

    Thanks!

  12. Hey guys, great site, but get back to updating it :P

    The idea is great but I think you need to update at least daily! You’ve advertised 4 times a day which is a lot. Why not give us something new?

    Good luck.

  13. why not just us xp pro and set up a shutdown script?

  14. thanks

  15. As long as you have WinXP Pro (not Home), you can configure your computer to run
    Windows Script Hosts (WSH) scripts at shutdown, as well as at startup, logon and
    logoff. This script (VBScript/JScript) can then again start external programs,
    e.g. like this:

    Set oShell = CreateObject(”WScript.Shell”)
    oShell.Run “cleanmgr /sagerun:1″, 0, True

    For Win2k/WinXP Pro, this is done by using a Group Policy Computer (GPO)
    Configuration Logoff and/or Shutdown script. The GPO can be activated manually
    with gpedit.msc.

    From the Start menu Run dialog, open: gpedit.msc

    for logoff script, under “User Configuration”,
    open Windows Settings\Scripts (Logon/Logoff)
    (double click, Add…).

    for shutdown script, under “Computer Configuration”,
    open Windows Settings\Scripts (Startup/Shutdown)
    (double click, Add…).

  16. %temp% is a good way to delete all of you temporary online content. Start>Run>%temp%, and then delete everything you see… This works for me.

  17. @jp: I am with your Comment

  18. Following is the entire script which you can use for PC cleaning.

    Filename: deltemp.bat

    REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    REM Script : Deltemp.bat
    REM Function : To Delete all temporary files, cookies & Internet Temporary files.
    REM Author : Ram
    REM Date : 4/25/2006
    REM Company :
    REM Dept : Dev,Testing,QA
    REM Version : 1.0
    REM Usage : This Utility has to be used ONLY for WINDOWS XP Professional Environment. Please donot use it
    REM for any other environment UNLESS you know how to make changes to the below code.
    REM
    REM Please replace my USERNAME with your USERNAME in your PC.
    REM
    REM Copyrights : None.
    REM Disclaimer : Please check back with me if you are unsure of:
    REM a. your username
    REM b. your PC configurations
    REM c. What Operating System you have OR in which you plan / intend to use this script.
    REM
    REM Prereq : Please check if your temporary internet folder is currently pointing to c:\Temporary intenet files
    REM folder. If yes, then you can run this script after changing your id, else please ask me for guidelines
    REM for a smooth setup.
    REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    REM Install : STEPS
    REM 1. Please save/copy this file ‘deltemp.bat’ to your C:\ folder.
    REM 2. Click on START & then RUN.
    REM 3. Enter ‘gpedit.msc’ in that window & execute the program.
    REM 4. Click ‘Start’ then ‘Run’
    REM 5. Type in ‘gpedit.msc’ and hit ‘ok’
    REM 6. Click on ‘Computer Configuration’ then ‘Windows Settings’
    REM 7. Double-click on ‘Scripts’ and then on ‘Shutdown’ (You can add it to ‘Startup’ also).
    REM 8. Click ‘Add’ and find the batch file that you created and then press ‘Ok’
    REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    REM Now if you are set to go, you can shutdown your PC or do a RESTART. That’s it.
    REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ATTRIB -s -h “C:\WINDOWS\Temp\*.*” /s

    del /S /q “C:\WINDOWS\Temp\*.*” /F

    REM The above step “Deletes all files in Temp folder”

    ATTRIB -s -h “C:\Documents and Settings\\Cookies\*.*”

    RD /S /q “C:\Documents and Settings\\Cookies”

    ATTRIB +s “C:\Documents and Settings\\Cookies\*.*”

    RD /S /q “C:\Documents and Settings\\Local Settings\Temp”

    md “C:\Documents and Settings\\Local Settings\Temp”

    ATTRIB +s “C:\WINDOWS\Temp\*.*” /s

    ATTRIB -s -h “C:\Documents and Settings\\Local Settings\Temporary Internet Files\*.*” /s

    rd /S /q “C:\Documents and Settings\\Local Settings\Temporary Internet Files”

    REM md “C:\Documents and Settings\\Local Settings\Temporary Internet Files”

    ATTRIB +s “C:\Documents and Settings\\Local Settings\Temporary Internet Files\*.*” /s

    ATTRIB -s -h “C:\Temporary Internet Files\*.*” /s

    del /S /q “C:\Temporary Internet Files\*.*”

    RD /S /q “C:\Documents and Settings\\Recent”
    REM — END of script ————
    REM —————————-
    Disclaimer: Nothing is warranted as is. Please CONFIGURE & CHECK all the above
    before running OR executing the script.
    SCRIPT cannot be run as is. Please change user-ids etc to suit your environment.

  19. Hmmm good one needs some modifications though :)

  20. use both “temp” and “%temp%” to open temp files in RUN commmand and then delete the files.it worked for me,,,,although a few of them may not get deleted

  21. hmm….gud script, just need some changes/modification and will be all set to use

  22. hey guys thanks for the temdelete bat file, it worked like a charm, unfortunately i can’t get it to work for the cookies and other folders.

  23. Greetings,
    This script is a very bad idea. This will remove all temporary storage for setups which keep files hidden in the Temp folder. Add/Remove applications in control panel will no longer work. First, do not remove hidden/system attributes. (REM ATTRIB -s -h “C:\WINDOWS\Temp\*.*” /s )

    Second delete *.tmp which is the most common file stored in the temp folder. This is much safer that delete *.* in all cases. (del /S /q “C:\WINDOWS\Temp\*.tmp”)
    This change also pertains to the %TEMP% path on the machine.

  24. Check out
    http://support.microsoft.com/kb/315246 to use CleanMgr.exe from Microsoft.

  25. Need a temporary files remover software. Is there any one who can do this ?

  26. Gooday Mate, This ::Delete your TEMP files on shutdown article above is fantastic have you got a RSS Feed

Post a Comment


Your email is never published nor shared. Required fields are marked *



© 2006-2007 Maxim Software Corp.  All rights reserved.