1

In the top voted comment of the best answer here (How to persistently set a variable in Windows 7 from a batch file?) it is mentioned that %PATH% expands to the system plus the user variables. Is that true? In my laptop if I open cmd and I digit

    echo %PATH% 

I only see the system variables. Can anybody clarify this point?

cheers A.

Community
  • 1
  • 1
Millemila
  • 1,612
  • 4
  • 24
  • 45

1 Answers1

6

The environment that is, by default, given to a new process, merges both system and user variables. So, if you have a PATH variable defined for both system and user then the two values are merged.

Your experiment appears to contradict my statement above. However, when I repeat your experiment I can see values from both system and user settings merged. So I can only conclude that you are not performing your experiment correctly.

Update: Perhaps this comment from the MSDN topic on environment variables might be pertinent:

Found out that on Windows Server 2003, once the system PATH passes 1920 characters, the user PATH environment variable is no longer merged with it to set the process PATH environment variable, even though the full system PATH (even if larger) will be included in the process PATH variable.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Yes there is a character limit. That fixed the issue. Thanks. – Millemila Jan 21 '14 at 23:39
  • 1
    I would like to add that even if some directories are stored by using other variables (like %comp%\redist\intel64\mkl ), what matters is the length of the EXPANDED path!! if the latter larger than 1920, PATHS are not merged, even if the non expanded is shorter!!! – Millemila Jan 22 '14 at 00:08