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

Solution 1:

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:

    ::setenv.bat
    @echo off
    set %1=%2
    setx %1 %2 %3