ghacks Technology News

Clear Temporary Files during System Shutdown

Windows does not automatically delete temporary files during system shutdown. This means that deleted files in the trashbin and temporary files like those in the Internet Cache are still accessible after a restart of the system. System cleaners like CCleaner or Disk Cleaner are able to delete those files but I would like to show a way how many of them can be deleted by using a Windows system tool.

We are going to configure the Disk Cleanup Settings in Windows to delete the temporary files and create a new rule that the software will be run during system shutdown.

Our first step would be to open the Disk Cleanup Settings and configure them the way we want. To do that you use the Run command in Windows XP / 2000 or the search in Windows Vista.

cleanmgr /sageset 1

This opens the Disk Cleanup Settings. Check the elements that you want to automatically delete. If you are unsure about an element click on it and read the description. This should give you a good understanding of it.

disk cleanup settings

Open the Group Policy Editor now. You do that in the same location where you started the Disk Cleanup Settings.

gpedit.msc

Navigate to User Configuration > Windows Settings > Scripts (Logon / Logoff) and double-click on Logoff.

logoff scripts

Click on Add and Browse in the next window. Right-click in the blank space of the Logoff folder and create a new text document. Name it cleanup.cmd. Open it with a right-click and add the following line to it.

cleanmgr /sagerun 1

Select the file cleanup.cmd and click Open and in the previous menu OK. The file that you created should be now in the list. Click on Apply and OK afterwards. Et Voila, we are done.

Everything that you selected during the configuration will now be deleted after every system shutdown.

Enjoyed the article?: Then sign-up for our free newsletter or RSS feed to kick off your day with the latest technology news and tips, or share the article with your friends and contacts on Facebook or Twitter.

Related Articles:

System Ninja, Another Portable Temporary Files Cleaner
Privacy Software BleachBit Deletes Temporary Files On Windows And Linux
AskForSanitize, Display Clear Private Data Prompt On Firefox Shutdown
Cleaning Out Windows Live Mesh Temporary Files
Create, Use And Clear Temporary Folders In Windows



About the Author:Martin Brinkmann is a journalist from Germany who founded Ghacks Technology News Back in 2005. He is passionate about all things tech and knows the Internet and computers like the back of his hand. You can follow Martin on Facebook or Twitter.

Author: , Sunday October 28, 2007 -
Tags:, ,


Responses so far:

  1. Ace_NoOne says:

    I’d tried a very similar method a while ago – though that one used a batch file with the following contents:
    RD /S /Q %TEMP%

    However, that didn’t really work perfectly (there were always a few files and folders left after a reboot), so I will give this a try now.

  2. asdf says:

    This thing makes shutdown take forever. Stick with the a batch file.

  3. Harry says:

    Thanks for procedure to delete tmp files at shudown, it was great.
    Best wishes for New Year
    Harry

Leave a Reply   Follow Ghacks   Subscribe To Comment Rss

Subscribe without commenting

© 2005-2012 Ghacks.net. All Rights Reserved. Privacy Policy - About Us