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 Windows temporary files?

Question:

In what I do, I have to handle pretty large files all the time. In my setup,
I have 3 hard disks:

  • C: which is meant to only run windows and barely has any space on it left
    after XP was installed.

  • D: which is where I store all my files.

  • E: where I want my temporary files to be.

How would you go about changing the location of the temp folder to E:/ in
Windows XP?

Aside from your small C: partition, you’re describing a reasonably good set
up. By moving your temporary files to E: you should not only get an improvement
in available space on C:, but things might also speed up just a tad.

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

First, I want to be clear to everyone that we’re not talking about Internet
Explorer’s temporary files. Those are controlled by settings in Internet
Explorer’s options. Similarly, many applications also allow you to specify
alternate locations for temporary files used by that application.

We’re talking about Windows itself.

Windows has a concept of a directory where it, and other applications if
they so choose, can place files that are for temporary use only.

Fire up a Windows Command Prompt, (typically in Start,
All Programs, Accessories), and in that
windows type SET followed by the Enter key.
Windows will list a number of what are called “environment variables” that make
various types of information available to running programs. Two of them will
look much like this:

TEMP=C:\DOCUME~1\LeoN\LOCALS~1\Temp
TMP=C:\DOCUME~1\LeoN\LOCALS~1\Temp

TMP and TEMP both specify the directory to be used for temporary files. Both
TMP and TEMP are used for compatibility reasons. In this example they actually
specify “C:\Documents and Settings\LeoN\Local Settings\Temp”, but in 8.3 compatibility
representation
.

Changing them is easy.

Right click on My Computer and click on
Properties. In the resulting dialog click on the
Advanced tab and you should see something like this:

System Properties dialog, Advanced tab

Click on the button near the bottom labeled Environment
Variables
, and you’ll see something like this:

System Properties, Environment Variables dialog

You may see both TMP and TEMP listed in the section labeled User
variables for (account)
. That’s the common location; each different
login account is assigned its own temporary location.

Personally, I prefer to have a single location for the entire system. So if
TMP and TEMP are present in the top list, I click on each and then click on
Delete. However you can simply edit them, as we’re about to
edit the System copies, if you prefer.

“… some programs can get confused if the temp
directory is set to the root of a drive.”

If you scroll down in the bottom list labeled System
Variables
you’ll find TMP and TEMP again. Click on one, and then press
the Edit button:

System Properties, Edit Environment Variable dialog

In the Variable value: edit box you can now specify a path
to a directory that Windows and many other programs should use for temporary
files. As you can see, I’ve specified a different directory entirely, but still
on the C: drive. You could specify “E:\” to use all of E: as your temporary
location, but I’d actually recommend creating a subdirectory on E:, such as
perhaps “E:\temp” and using that, as some programs can get confused if the temp
directory is set to the root of a drive.

Be sure and repeat that process for both TMP and TEMP.

You’ll need to restart any running programs for the new value to take
effect. In fact, you’ll need to restart Windows for it to begin using the new
value for its own temporary files.

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!

33 comments on “How do I change the location of Windows temporary files?”

  1. How do I know if I have more than one hard drive?
    I know I have C:, however, when I had to reformat and install windows XP clean, it deleted and re-created a new C: drive…
    I am not sure if I have a D: or E: drive….
    If so, how do I find out if I have one or the other?

    Reply
  2. —–BEGIN PGP SIGNED MESSAGE—–
    Hash: SHA1

    Apeke: drives should be listed in Windows Explorer.

    You might also try disk manager: Right click on “My Computer”, click on
    “Manage”, click on “Disk Management” and that should show you what you have.

    Leo
    —–BEGIN PGP SIGNATURE—–
    Version: GnuPG v1.4.6 (MingW32)

    iD8DBQFGGT4jCMEe9B/8oqERAm4lAJ43CkIh6zs18A/jO6MsTryn+Bb9iwCfR3GX
    PaNs22kmVZoWlknDWdukaZc=
    =vnem
    —–END PGP SIGNATURE—–

    Reply
  3. I have made the changes above because I had the same problem with a small partition as system disk which kept filling up. I’ve also moved the location of IE temp files. I now have programmes that won’t start – I use Adobe CS3 and non of the programmes will start. I tried uninstall to reinstall and the system said that critical files are missing. When inserting the disc to reinstall CS3, it gets as far as Adobe set up window, then it goes off the screen without continuing set up. Please help – what have I done????? FYI I have renamed temp files G:\Local Settings\Temp. Many thanks

    Reply
  4. Nice little guide! It might also be beneficial for this person to put their swap file on E: if that’s a fast drive.

    One thing I can’t figure out though: How do you tell Windows XP where to put its Windows Update temporary files? It seems to just pick the drive with the most free space, which is not what I want it to do.

    Reply
  5. Thank you – you saved me! I have Windows XP on a partition, and I tried copying a batch of files from an external drive to another partition, next thing you know Windows has spat its dummy because the C: drive is full (to the brim!). I was dreading the prospect of having to reboot from scratch, but now I’ve changed the location of the Windows temp folder – so big thanks!

    Reply
  6. How can I install Adobe reader to my E drive?
    Dear Leo,Thanks so much for the help. I have a new problem: according to your instruction, I changed TEMP and TMP to E:?TEMP,but the Adobe is a;ways installed to C drive not E drive, very anoying. Please help me to install all temperary file to E drive because my C drive only has less then 15% mem left. Thank you.

    Reply
  7. I tried to do this in Windows 7 (change the variable value to D:\TEMP) but I don’t see TEMP folder in the D drive.

    You have to create the folder first before it can be used. Setting the TMP variable only tells Windows what folder to use, it will not create that folder.

    Leo
    29-Nov-2009

    Reply
  8. Thanks Leo. I have another question. What happen if I also edit the TMP and TEMP under User Variable for ?

    Same thing. Those are user-specific settings, and apply to you when you’re logged in. You can delete them and the system settings will take over, or you can set them to whatever you like.

    Leo
    02-Dec-2009

    Reply
  9. In Windows 7, under User variable for the value for TEMP and TMP is %USERPROFILE%\AppData\Lacal\Temp, and under System variables the value for TEMP and TMP is %SystemRoot%\TEMP. How do I change it to another drive? Thanks.

    Just set it to the explicit path, like “D:\MyTempFolder”

    Leo
    01-Dec-2009

    Reply
  10. Hello!
    Usually I have 2 accounts (admin and user) in my WinXP and I use this method to keep temp files in one location. I.e. both account’s temp folder and the system temp are same. Also this needs some security tip. Because all accounts (admin, user and any built-in ones ) and the system access same folder, I change the folder’s permission as “Everyone | Full access”. And my question: recently I moved to Win7 and found that I can use this method only for admin account. When I’m trying to access “Computer | Advanced system settings” (where Environment var-s located) from a standard user account, I have to switch to the admin acccount, so I get env var-s of the admin. In WinXP there was no problem. Any help?

    Reply
  11. Thanks for the article. However, if I would like to have temp environment changed for all my users who logon to a Terminal Service, how do I do that. Is there a registry entry which I could change? I need to change it for all my users do to an application which does not like long paths for TEMP.

    Reply
  12. Does this move the files, or just change the pointer for any new entries? I want to actually MOVE the filter in my current TMP and TEMP folders. I have used the above operations, and it works for any new entries. But, I am afraid that, if I move the current info to the new locations, it will screw up any previous file installations and/or registry entries.

    Reply
  13. Instead of using the GUI is easier to just use the command prompt as:
    SET TEMP=F:Temp (replace with desired location)
    SET TMP=%TEMP%

    Reply
  14. great post. Have been looking for how to do this forever as my main drive is a ssd to its not the biggest, now i can work with large files without getting errors.

    Thanks alot

    Reply
  15. I’ve been having this issue the past two days since I did the same thing! I only gave xp about 9 gigs of space and now it’s freaking out..can’t download anything..i moved my internet temp folders but couldn’t figure out how to move the windows temp files. Thanks so much!

    Reply
  16. Very useful, except I cannot find the command prompt command, it’s not where Windows says it should be (in the start/accessories section). Do you have an idea where it might be hiding pease ?

    Dank u wel

    ernie

    Just click on Start, Run and then type in “cmd” as the command to run. That’s the Windows Command Prompt.

    Leo
    22-Jul-2010

    Reply
  17. Great post, I’m running out of space and now I can free some – THX !
    And to give something back – Start, Run = WindowsKey+r

    Reply
  18. Using cmd/command prompt to change these variables is not effective. It will only change them for that cmd session.
    You must use the GUI if you want the changes to stick.

    Reply
  19. Wielkie dzieki from Poland, Leo!
    At last, I’ll be able to get the whole 9-hours-long parliament session downloaded :)
    If only I could know why the IE chooses once “Temporary Internet Files”, once “Temp”…

    Reply
  20. Thanks, Leo!

    Is it okay if I use an External Drive for the temporary files, instead of the Internal one?

    You can, but it will likely slow down your system, potentially a lot, as external drives are often much slower than interal.

    Leo
    13-Jan-2012
    Reply
  21. My friend computer locked & all default users & admins are diabled how to hack the machine without formating xp Sp 3…?

    How to crack xp Admin password ., while all default accounts are diabled …..

    Reply
  22. After changing the path for TEMP and TMP i rebooted the system, but no change in size filled of my SSD drive (Boot Drive), so i checked, they were not moved to the new location (obviously) and almost everything in the Temp folder (at the usual location) was gone.
    After trying a few times more i found out (here) that i need to create the folder first at the new location, i did so, and tried again.
    Again, no luck and i still can’t figure out where my Temp files went and my main drive (SSD) was still 49GB/58GB (filled).
    Any had same situation and solved it? i can’t find a solution

    Reply
  23. I would like to thank you very much for the help that you done for me. I was in a bid trouble with that. So you solved that. Thank you very very much Leo.

    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.