Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What the title says.

On windows, how do I set an environment variable for a user other than the currently logged in one. I need to set the TMP variable to change the temporary directory used by a app.

share|improve this question
As an unrelated comment: Why in the world would an ASP.NET application look to the computers Env. variables for a file path setting? AppSettings are built-in for that reason alone. – Brent Pabst Jun 12 '12 at 16:48
Also, this question is off topic for ServerFault, it should be posted on SuperUser – Brent Pabst Jun 12 '12 at 16:51
@BrentPabst - The standard temp directory api in .Net reads from it -… – George Mauer Jun 12 '12 at 18:26
Right, so what user is your application running under? Does it change that context each time a user logs in? Typically in IIS this is not the logged in user. – Brent Pabst Jun 12 '12 at 22:10
@BrentPabst - I don't get what you're getting at. It runs under the same context every time (Network Service). But rather than setting the TMP variable for the entire server, I want to set it just for that user. I think what uSlackr recommends is going to work. Are you proposing another approach? – George Mauer Jun 13 '12 at 12:46
up vote 6 down vote accepted

You can access through the registry. Modify the \Environment\Tmp key in HKEY_Users\<their SID>

share|improve this answer
Inspired by this answer, I was able to figure out how to do this via Chef. – Kenny Evitt Feb 9 '15 at 0:12
Is there an elegant way to get the SID of a user?. Particularly a virtual account?. – user1570690 Sep 15 '15 at 3:01
You could ask that as another question, but if you do a google search for get sid of application pool identity, the first result,, has a pretty elegant solution. – austinian Sep 25 '15 at 10:08

Your Answer


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.