Technology in terms you understand. Sign up for the Confident Computing newsletter for weekly solutions to make your life easier. Click here and get The Ask Leo! Guide to Staying Safe on the Internet — FREE Edition as my thank you for subscribing!

How Do I Change the Location of the Windows Temporary Files Folder – and Should I?

Question:

How to change the default location for the temporary file folder to a different hard disk?

In most cases, there’s no reason or need to fiddle with this setting; its default setting is quite appropriate for most common usage.

However… Smile

That “different hard disk” you mention in your question opens the door to some scenarios where it actually is a useful setting to change.

I’ll show you how and then discuss some of the scenarios where it might make sense to change.

Become a Patron of Ask Leo! and go ad-free!

TMP versus TEMP

First, let’s clear up one point of confusion.

For historical reasons, settings called both TMP and TEMP are used to indicate the temporary folder that Windows will use. “Historical Reasons” means that the setting is called “TMP” on the Unix operating system from which much of this geekery was modeled, but someone along the way said “it should be more readable” and added the “E” to turn it into something more like a word. The problem of course is that not all programs changed, and thus both had to be supported. Forever.

“There are two scenarios where changing the location of the temporary folder makes some amount of sense, and both involve using a different drive.”

It’s not uncommon for things that seem odd to be there because of “backward compatibility”, and this is one.

Unless I say otherwise, I’ll use TMP to refer to both TMP and TEMP.

My TMP Versus Your TMP Versus Windows TMP

Windows is a multi-user operating system, even though we typically run it one user at a time, and even then, Windows itself is kind of its own user.

The upshot is that each user login gets its own TMP setting, and the operating system gets its own as well.

Thus, there can be many TMPs.

Show Me Your TMP

Let’s look at where to change ’em.

Right-click on “My Computer”, or “Computer” – either in the start menu or desktop – and click on Properties.

Click on Advanced or Advanced System Settings and you should get a dialog much like this one:

Windows 7 System Properties: Advanced

Click on the Environment Variables button to get this:

User Environment Variables in Windows 7

Right away you can see that the TMP settings for the currently logged-in user – me in this case – are displayed right at the top. %USERPROFILE% is replaced with “C:\Users\LeoN” in my case, so the temporary files are actually in “C:\Users\LeoN\AppData\Local\Temp”.

If you click in the lower box and scroll down, you’ll see that there’s another pair of settings:

System Environment Variables in Windows 7

As you can see, both TMP and TEMP are here as well, and are set to “C:\Windows\Temp”.

The operating system will use “C:\Windows\Temp” as its temporary files folder, and programs that you run will use “%USERPROFILE%\AppData\Local\Temp”.

One Simple Change

To the best of my knowledge, you don’t need both. By that I mean you don’t really need separate settings for your login accounts and for the system. (If you’re at all hesitant, you don’t need to make this change.)

So one approach that I frequently use is to simply delete the TMP and TEMP settings from the “User variables” portion. Click on each, click on Delete and they’re gone.

Empty User Environment Variables in Windows 7

If you have no user-specific TMP setting, the system setting will be used instead. In other words, all the temporary files will end up in the same folder.

Changing the Location

To change the value of the TMP and TEMP variables, double-click on one to get this edit box, and type in the new value:

Changing the TEMP environment variable

Here you can see I’ve replaced the value with “d:\tmp”, a folder I’ve created on one of my hard drives.

Press OK, repeat for TMP, and you’re done.

Well, you may have to reboot for the changes to take effect.

A couple of notes about making the change:

  • The folder must exist – Windows will not create it for you. If it doesn’t exist, it’s unclear what will happen, but most likely Windows will put the temporary files in a random location, or some programs may not work at all.
  • As I said, you may need to reboot for the changes to take effect completely.
  • Only after you reboot should you clean up the “old” temporary folders. I recommend removing their contents but leaving the empty folders around.
  • Resist the urge to get tricky with the folder names or paths. The TMP setting is used by many, many programs some of which may not behave properly with spaces in file names, lengthy paths, or settings that are anything other than simple. Yes, even after all this time.

Why Change?

There are two scenarios where changing the location of the temporary folder makes some amount of sense, and both involve using a different drive. If you’re moving it from one location on C: to another location on C:, you’re not really improving anything.

Speed: If you have a separate physical drive, it can sometimes be a small speed improvement to place your temporary files on that drive. Exactly how much, or even if this will benefit you is extremely dependent on your system configuration and how you use your computer. It’s even possible that it could slow you down. But since it’s a relatively simple change, it’s one of those changes that you can experiment with to see if the results are beneficial.

Space: If your C: drive is filling up, but you have lots of space on, say D: – then moving the temporary files folder can allow you to free up that space on C:. In this case C: and D: could be two partitions on the same drive, or different drives, it doesn’t matter. My only suggestion is that you first empty your TMP folder before you go through the effort of moving it – things frequently accumulate there and a simple cleaning may well resolve your issue.

Finally, be aware that this is not related to your internet browser in any way. Your “Temporary Internet Files” is a different animal completely, and is controlled by the web browser or other internet program you happen to use.

Do this

Subscribe to Confident Computing! Less frustration and more confidence, solutions, answers, and tips in your inbox every week.

I'll see you there!

9 comments on “How Do I Change the Location of the Windows Temporary Files Folder – and Should I?”

  1. I’ve often wondered why there as so many TMP/TEMP folders lying around, and why one is used versus the other.

    Seems obvious now, but something I hadn’t thought of before. That explains it.

    Another great article. Thanks Leo!

    Reply
  2. Don’t do this with Vista, as some programs can’t cope with it, and give puzzling error messages. E.g. SP1 installation, Acronis True Image 11.0 installation. It’s OK with XP.

    Reply
  3. I probably would do this because I have a tiny boot drive for safety – 30 gb [ virus, etc ]and all real data is stored on other mirrored drives but haven’t had the need since the only things on the boot drive is the OS and programs folder – less than 10 gb. The temp folder has plenty of space to play with.

    Reply
  4. Is it possible to use a RAM disk for storing temp files. The advantage, providing this can be done, would be faster speeds since writing to RAM would be faster than writing to hard disk. Additionally the temp files would get cleared on re-boot. If this is practicable and feasible how does one go about doing this? Is it possible to create a RAM disk using a batch file which will get executed at start up?

    Reply
  5. I’ve changed that setting once and forgot to create that folder and started seeing a folder popping up all over the place with just the letter c as the name. There was one in Windows and some program folders had one, if I remember correctly.

    Reply
  6. The reason i changed my TMP folder is because my C: drive is a SSD dirve.
    The benefit is they are realy fast in reading, the major disadvatage with these drives is they are very, very slow in sequential writes.
    My next (storage) drives are normal harddrives, for TEMP drive its far more better to use a conventional drive (TEMP folder and IE cache) than a SSD.

    I used your example and my computer is flying, thanks a million! -JW-

    Reply
  7. This is for Uday Rege, who wanted to know whether it might be possible to use a RAMdisk for his TEMP folder.

    This is theoretically possible — but UTTERLY inadvisable, and that for at LEAST two reasons:

    1. Firstly, badly-written or ill-behaved programs sometimes actually put their executables there! With the natural consequence that a program stored in the TEMP folder isn’t “temporary” at all! There is no conceivable good reason for any program to do this, but some have been known to do so, so be warned: emptying your TEMP folder (which SHOULD be harmless) may actually BREAK something!

    and

    2. Secondly (and far more importantly) the TEMP folder is very frequently used by installation programs during the reboot sequence to store “partial installer programs”, the running of which continue or complete the installation of some program that was begun prior to system reboot. If that folder happense to be a RAMdisk, that gets cleared every time you reboot your computer, well, guess what? That program you’re trying so hard to install, will either NEVER install at all, or else never install completely or correctly, as the files it needs to complete installation on reboot vanish out from under it during the reboot sequence!

    Bear in mind, that installation programs of this kind — the kind that need a reboot to complete their installation, and pick up with and continue the installation after reboot — frequently include “patches”… including those supplied by Microsoft, among others.

    Catch my drift? It may sound  like a nifty idea, but DON’T do it!

    Reply
  8. A third reason for moving not only TMP/TEMP but also Temporary Internet Files and similar ephemerals is when using something like RegShot, a simple but v. useful wee program that can take and compare different snapshots of any or all drives, plus your registry, enabling you to compare before-and-after scenarios.

    By moving temp file locations of all sorts (pagefile/hiberfil.sys are ignored automatically) to a dedicated, and unmonitored, drive, the differences to be examined are much reduced.

    Reply
  9. You say that “The TMP setting is used by many, many programs some of which may not behave properly with spaces in file names”…

    One comment – the same applies for user names. When I setup my computer I had a space in my username and now my %userprofile% expands to a path with a space in it. I have only had one thing cause me problems because of this in the last 8 years or so and that was a batch file distributed to patch a beta program failed because they didn’t enclose the userprofile variable in “” marks.

    Reply

Leave a reply:

Before commenting please:

  • Read the article.
  • Comment on the article.
  • No personal information.
  • No spam.

Comments violating those rules will be removed. Comments that don't add value will be removed, including off-topic or content-free comments, or comments that look even a little bit like spam. All comments containing links and certain keywords will be moderated before publication.

I want comments to be valuable for everyone, including those who come later and take the time to read.