Why doesn't environment variable get updated in cmd without restart?

Posted by John Nevermore on Super User See other posts from Super User or by John Nevermore
Published on 2013-11-03T01:41:01Z Indexed on 2013/11/03 3:58 UTC
Read the original article Hit count: 402

CMD commands:

setx SOMEVARIABLE "newpath" /M
setx SOMEVARIABLE "%SOMEVARIABLE%;newpath2" /M

Expected output on ECHO %SOMEVARIABLE%:

newpath;newpath2

Actual output:

%SOMEVARIABLE%

Actual value stored (From System Properties->Environment Variables GUI):

%SOMEVARIABLE%;newpath2

The only way i can get the expected output is, if i restart the command prompt every time i modify the environment variable. I'm using this command to automate environment variable value appending multiple times during the same process.

  1. Why doesn't environment variable get updated in cmd without restart?
  2. Is it possible to get the updated value of %SOMEVARIABLE% without restarting the command prompt?

© Super User or respective owner

Related posts about windows-8

Related posts about environment-variables