Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
8  
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
2  

2 Answers 2

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
2  
Also run that script on startup so that the folder gets deleted even if your computer crashes. –  Andreas Hartmann Aug 22 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

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.