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

CMD commands:

setx SOMEVARIABLE "newpath" /M

Expected output on ECHO %SOMEVARIABLE%:


Actual output:


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


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?
share|improve this question
up vote 4 down vote accepted

The problem is that setx modifies the global environment, not the local environment. Therefore, you have to restart the command prompt to pick up the change.

You have two options:

  • Use a different tool that modifies the global environment and the local environment
  • Create a batch-file that does both and use that:

    @echo off
    set %1=%2
    setx %1 %2 %3
share|improve this answer

You must log in to answer this question.

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