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

I need to mark some folders on my C: and D: drives as temporary, so that all contents saved in them get deleted after shutdown.

How can I do that?

share|improve this question
You should phrase that as a question and give us some additional information like which OS you are using... Obviously it is Windows so you could try a shutdown script. – Simon Mar 25 '13 at 9:34
Running a script on boot time will be much easier. Place the script in startup folder. – mnmnc Mar 25 '13 at 10:33

Assuming you're on Windows, write a script to delete the folders in question. You could also do this on start up to create the folder(s) (if applicable to your situation).

Open up gpedit.msc (local Policies) - > Computer Configuration -> Windows settings -> Scripts -> Shutdown / Startup -> Add

share|improve this answer
Also run that script on startup so that the folder gets deleted even if your computer crashes. – Andreas Hartmann Aug 22 '14 at 10:06

The gpedit.msc answer worked for me in the past. I even upvoted it. I also tried Unlocker and MoveOnBoot. Both have the ability to delete the folder on next restart. Unlocker can handle most deletes but my particular situation was too difficult for it.

Here's what worked for me. It uses Task Scheduler to run the delete task at system startup.

  1. Open Task Scheduler. Press Win+R and run control schedtasks.
  2. Create Task.
    1. General tab
      1. Provide a name
      2. Select Run whether user is logged on or not
      3. Check Run with highest privileges
      4. Configure for Windows 7, Windows Server 2008 R2
    2. Triggers tab
      1. Press New...
      2. Set Begin the task to At startup
      3. Press OK
    3. Actions tab
      1. Press New...
      2. Set Program/script: to C:\windows\system32\cmd.exe
      3. Set Add arguments (optional): to /c rmdir /s /q C:\some_directory
      4. Press OK
    4. Conditions tab
      1. Clear all check boxes
    5. Settings tab
      1. Check Allow task to be run on demand
      2. Check Run task as soon as possible after a scheduled start is missed
      3. Clear remaining check boxes
      4. Set If the task is already running, then the following rule applies: to Run a new instance in parallel
    6. Click OK
share|improve this answer

You must log in to answer this question.

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