In Unix-like systems, generally /tmp is wiped on shutdown (there are some exceptions to this, but most of the time you can rely on this).

Is there a directory in Windows 10 that can guarantee this deletion? I have heard of %TEMP% but my (outdated?) understanding is that only some computers have it set up to wipe every time the computer is shutdown. And what is the status of this solution for older versions of Windows?

A related question: Is there a way to store files in RAM in Windows? This of course will guarantee the behaviour I want.

EDIT: It seems like there isn't a good place in a default factory setup of Windows. In that case, I might have to hack away at this one. Is there a common program that has a folder that it deletes regularly, or on shutdown? I'm wondering about something like a web browser cache, or a Microsoft Word "rescued backups" folder?

Use case: I'm wanting to put some private files somewhere when I use someone else's computer. I want these to be gone when I've finished using them (say, an hour later). However, I can't guarantee that I will be there to delete them - perhaps a powercut happens, or we get distracted and I don't have a chance to return to delete them. I also don't want to mess with the other person's computer or settings, so creating a scheduled task to delete them is not an option.

  • 4
    Short answer: there isn't one. Ram is possible using a ramdisk, but that too requires setup. If you want this, you can as well create a script that deletes the content of a folder upon shutdown.
    – LPChip
    Commented Oct 31, 2017 at 8:01
  • With the Fall Update of Windows 10, it is at least possible to have 'old' files deleted automatically. I haven't really looked in to this, but there is a setting for files in the Downloads folder, and (I think) %TEMP% as well.
    – Berend
    Commented Oct 31, 2017 at 8:43
  • @Berend That isn’t a new setting.
    – Ramhound
    Commented Oct 31, 2017 at 11:53
  • @Ramhound, I suppose you're right. I never noticed the setting, and read this article only a few days ago. They certainly make it look like it's a new feature: windowscentral.com/…
    – Berend
    Commented Oct 31, 2017 at 13:16
  • Storage Sense is indeed a new feature, but, Windows has allowed you to configure how long temporary files were kept since Windows XP was released.
    – Ramhound
    Commented Oct 31, 2017 at 13:49

2 Answers 2


As mentioned in the comments, you may be able to use Storage Sense to achieve what you want, although it's not really designed for the task you describe.

A better alternative is to create a script and hook it up to run on shutdown or logoff using Group Policy Editor.

(Note that Group Policy Editor is only available in Windows Professional and Ultimate editions. Apparently there are ways to install it in Windows Home, although I haven't tried this myself.)

  1. Create a .cmd script like the following:

    del /q c:\tempfiles\*

    Or you can use a Powershell .ps1 script if you prefer, like this:

    cmd /c "del /q c:\tempfiles\*"

    Save this script where ever you feel is appropriate.

  2. Press Windows Key + x to open the 'Power User menu', then press R to open the Run dialog box.

  3. Type gpedit.msc and press enter. This should open the Group Policy Editor.

  4. Go to User Configuration -> Windows Settings -> Scripts (Logon/Logoff). Alternatively you can use Computer Configuration -> Windows Settings -> Scripts (Startup/Shutdown), although personally I have had difficulties with getting shutdown scripts to work properly, and using a Logoff script will cover sleep mode, so may be a better alternative.

  5. Double click Logoff on the right side panel

  6. Add your script as appropriate.


Assuming your unwanted files are in the C:\temp folder, write a text file containing these lines:

del c:\temp*.* /q /f

shutdown -s -t 0

Save it as (for example) CLOSE.CMD on the desktop

Double-click the CLOSE.CMD icon to delete the folder contents and shut the PC down .

  • 1
    Thanks for your thoughts. It might work for some people, but unfortunately as described in my question this does not guarantee deletion on shutdown - it requires the user to only shutdown via the command, not the normal method.
    – eedrah
    Commented Oct 31, 2017 at 17:58

You must log in to answer this question.

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