Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Is it possible for one of you to write a script for removing the temp files during logout for all users? (or server during restart)

Or this script can be scheduled alternate weeks.

As unnecessarily it will fill up the C drive otherwise.

share|improve this question
up vote 0 down vote accepted

You don't want to do this or your windows updates and any other software installation needing a reboot to finish installation will fail. We tried something similar and regretted it...
I would recommend that you create a .bat file that you train your users to run after they boot up and before they open any files/programs...
You could start with:

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

If you want to delete other temporary locations, you would need to add them according to your environment...

share|improve this answer
There's a very easy way to avoid the problem you encountered - check each files Accessed Date attribute, and only delete files that have not been accessed in X weeks/months. – Izzy Sep 23 '09 at 15:44
@Izzy: Maybe I missed something, but when trying that, I noticed that some installers did not change that attribute and it was still set a long time in the past, yet had just been added to the hard drive recently... – Scott Lundberg Sep 23 '09 at 16:38
Then check on the parent folders Accessed date/time. In fact, if it was me, I'd check for the Accessed, Created, and Modified dates, and if any of them were within the last 3 months I'd leave it. – Izzy Sep 24 '09 at 15:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.