Jump to content

Is it possible to change the location of Temp?

Recommended Posts

As the title says. Is it possible to change the location of the TMP and Temp variables before installation?

I want to be able to move them all to, say E:/tmp/ without having to go through the registry manually after the installation.

I've checked around in the Hivedef.ini and other hives. I only found one listing, changed that, but it didn't work. Temp was still located in C:/Windows/Temp and D:/Documents and Settings/xxxx/... (I've used winnt.sif to change userdir location)

I've thought about adding regtweaks that are installed post-install, but I'd rather try to get it done in the middle of installation.

Link to comment
Share on other sites

True. But I'm not certain about what regtweaks that will be needed to change all temp variables to another destination.

If someone has done this before, it would be great if they posted what they did to make it happen.

Isn't those variables supposed to be located in the i386 folder somewhere? Hive seemed to be the most likely place, but I couldn't find the correct place to edit.

Link to comment
Share on other sites

I know that, but I need to change them before I have the ability to go to My Computer Properties. I'm talking about doing this unattended, during the installation preferably.

Also: If you change the variables in the path you specify, not all of the temporary files are created in the new place. There are still numerous listings in the registry that points to the old location.

Link to comment
Share on other sites

That set the tmp location to there

than it returns the normal tmp varibles

echo off
mode con: Cols=55 Lines=5
color 1f
mkdir %systemdrive%\123
mkdir %systemdrive%\123
set tmp=%systemdrive%\123
set temp=%systemdrive%\abc

echo %tmp%
echo %temp%
set /p = Here Are The Temp Dir

Link to comment
Share on other sites

@gunsmokingman: your commands will only work for that batch file, it's not permament. This however is:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
"TEMP"="temp directory here"
"TMP"="temp directory here"

This will only change the Windows\Temp directory though, not the user variable (which is set to %UserProfile%\Local Settings\Temp).

Link to comment
Share on other sites

Thanks for the regkey, Tsunami. But as you said. That does not work for the user variable.

It is propably possible to export out all the user variables and append them on a new install... But that is not what I would like to achieve.

There must be a way to edit this in one of the files on the XPCD. These environment settings must (logically) be created by something.

But sadly it seems like the solution is buried deep withing the files of i386...

Link to comment
Share on other sites

I am using this code to do the job :

start /wait %SystemRoot%\system32\setenv -m TEMP C:\Temp\Admin\Temp

start /wait %SystemRoot%\system32\setenv -m TMP C:\Temp\Admin\Temp

mkdir %systemdrive%\Temp\Admin\Temp

start /wait %SystemRoot%\system32\setenv -u TEMP C:\Temp\Admin\Temp

start /wait %SystemRoot%\system32\setenv -u TMP C:\Temp\Admin\Temp

You can find this prog here :



Link to comment
Share on other sites

Continue searching. ;) There are a couple of more places to edit. (I know about them, I've editet them manually before...)

Anyway. I think fedek9001's solution is the best one I've encountered if there is no possibility to edit one of the files in i386.

And fedek... You can combine some of the syntaxes on setenv. So you only need this.

md E:/Temp
setenv -umd temp E:/Temp
setenv -umd tmp E:/Temp

Link to comment
Share on other sites

I think the registry keys you are after are in HKEY_USERS\.DEFAULT,

They are created as type REG_EXPAND_SZ, for the environment variables they use. To set them at their default values or any other using environment variables you could do it with a batch type command:

HKU\.DEFAULT\Environment /v TEMP /t REG_EXPAND_SZ /d "%USERPROFILE%\Local Settings\Temp" /f
HKU\.DEFAULT\Environment /v TMP /t REG_EXPAND_SZ /d "%USERPROFILE%\Local Settings\Temp" /f

If you dont need environment variables in the location, you could use a normal reg file containing:


If you wanted to just use the same location as Windows temp you could use the batch method above the reg or also an inf, by adding one of these:


HKU\.DEFAULT\Environment /v TEMP /t REG_EXPAND_SZ /d "%SystemRoot%\Temp" /f
HKU\.DEFAULT\Environment /v TMP /t REG_EXPAND_SZ /d "%SystemRoot%\Temp" /f



It would probably need installing at T13 /T12 from cmdlines.txt or equivalent

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...