Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ubuntu deletes temporary files by default after reboot, but Windows doesn't. How to make Windows to do the same?

share|improve this question
IE temp files or windows temp files? ( %temp% folder) – Lorenzo Von Matterhorn Mar 18 '13 at 11:04
%TEMP% (c:\users\user\appdata\local\temp) – mystdeim Mar 18 '13 at 11:06
Linux has two temporary folders: /tmp gets wiped at reboot, /var/tmp doesn't. In Windows, it's harder to decide which files can be deleted safely. I have seen applications that even stored their executable in the temporary folder (a driver, IIRC, and no, it wasn't malware). Deleting only temporary files that haven't been accessed for X days would probably be a better approach. – Dennis Mar 18 '13 at 11:51
Why would one do it at every startup? That's a waste of time. Plan to do such cleanup once a week or month. – Robert Niestroj Mar 18 '13 at 18:44
up vote 36 down vote accepted

Instead of going through the trouble (and danger) of doing this manually, I would recommend a program like CCleaner which can automate this process and leaves alone files that were created within the last 24 hours.

This is quite important, since some programs that might also run on startup could already be using temporary files, potentially causing issues. On Linux, the /tmp directory is known to be cleared out on every reboot, and all Linux programs are therefore designed around that principle.

Here's how to make CCleaner start with Windows: CCleaner options

Make sure only "Temporary Files" and other things you really want to clear on every startup are checked: CCleaner selection

CCleaner should only delete files over a day old by default, but it doesn't hurt to check this setting: CCleaner advanced options

After all this is done, CCleaner should run quietly in the notification area at every startup. The icon will disappear when cleaning is complete. CCleaner tray icon

share|improve this answer

I don't think there's an option for that. You can create a .bat file to delete the temporary files and make it run on startup (when Windows starts). The following should work:

Delete all files in %temp% but leave the folders untouched:

@echo off
del /s /f /q "%temp%/*.*"

Delete everything on %temp%:

@echo off
rmdir /s /q %temp%
md %temp%

Delete all .tmp files:

@echo off
del /s /f /q "%temp%/*.tmp"

Be aware that some programs use files in %temp% to run so do this at your own risk.

To make the .bat run on startup follow this tutorial from Microsoft or one of the many others online...

share|improve this answer

As a matter of fact, it is a waste of processor time to perform such a cleanup every startup.

Instead, add a scheduled task, triggered once a week to execute a batch located in the same directory of ccleaner, containing:

ccleaner /AUTO

This will perform a scan and automatic cleanup without any prompts to all boxes ticked on ccleaner and WILL include user-specified directories. (does not perform registry fixes)

extra tip: on batch properties, you may even select it to run minimized, so it bothers you less on the startup; the scan will be rather quick and probably you wont even notice the minimized window.

share|improve this answer
Is there some evidence that this is a factual matter? o.O – Smithers Feb 5 '15 at 18:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .