Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

I need to understand how Global vs User variables works in windows.

Case 1: If the same variable is defined at user and global section what is the behaviour? E.g. I have defined a %PATH% variable either in user and global sections and I see only global value; is there a way to 'append" user PATH to global PATH?

Case 2: The variables defined in user section are not 'resolved' in global section. If I use SET command I see a list of all defined variables (user and global) but 'cross references' are not resolved.


in user section I define:


in global section I define:


with SET I see:


I'm on a Windows 7 x64 box.

So, based on the tests above, my conclusions are:

  • global variables override user variables (if the name is the same only global is valid)
  • no cross reference is admitted between user and global variables

Am I right?

share|improve this question
Can I assume you're writing a batch file? – Dave Aug 7 '12 at 10:11
@martineau What I wrote above are my tests. I suppose a behaviour that I added in an update to my question, but I don't know if that's a correct interpretation of my tests. – Andrea Colleoni Aug 7 '12 at 10:15
@Dave no, I'm configuring windows manually thorugh 'control panel > system and security > system' and then restarting a CMD session at every change. – Andrea Colleoni Aug 7 '12 at 10:19
To answer part of question, I'm pretty sure that user vars can reference system vars. – martineau Aug 7 '12 at 10:23
up vote 5 down vote accepted

Your conclusions aren't quite right, at least according to my testing.

  • User variables can reference system (global) ones.

    System variables cannot reference user variables.

  • User variables will override system (global) ones.

    Just in the default set, TEMP (and TMP) are defined as the user variable as %USERPROFILE%\AppData\Local\Temp and at the same time as the system variable as C:\Windows\TEMP.

    PATH appears to be a special case, where the user variable PATH (if defined) is always appended to the system variable rather than overriding it.

share|improve this answer
My tests confirm all but one thing: user's PATH is not appended to global's PATH, but overrided by it. In my configuration they're written in different case: it matters? – Andrea Colleoni Aug 7 '12 at 10:34
@AndreaColleoni Case should not matter. If I create a user variable named PATH (or path) with the value C:\test, save (press OK), open a new command prompt and type echo %path%, C:\test appears on the end. – Bob Aug 7 '12 at 10:37
I've done as you said. I've also renamed user's PATH to USER_PATH and saw that global's PATH is automatically prepended to USER_PATH. If I leave the two named PATH I see only PATH's global value. – Andrea Colleoni Aug 7 '12 at 10:59
@AndreaColleoni USER_PATH has no special meaning for me. Your system may be different from mine for whatever reason... Could someone elase try & confirm it one way or the other? – Bob Aug 7 '12 at 11:06

You must log in to answer this question.

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