2

When I set an environment variable through the setx command in Windows 7, the variable is correctly set but if I type in set, it list the environment variables that were set at the script start up, not now.

I am wondering if there is a way to refresh the environment variables in the current batch session ?

My aim is to have such script to install my environment:

@REM set the environment variables
SETX M2_HOME "D:\softwares\apache-maven-3.1.1"
SETX JAVA_HOME "D:\softwares\java\x86\jdk1.7.0_40" 
SETX ANT_HOME "D:\softwares\apache-ant-1.9.3"

@ Reuse the previous variable to add to the PATH
SETX PATH "%PATH%;%ANT_HOME%\bin;%JAVA_HOME%\bin;%M2_HOME%\bin"

1 Answer 1

1

The answer is no, but there are several workarounds discussed here: https://stackoverflow.com/questions/171588/is-there-a-command-to-refresh-environment-variables-from-the-command-prompt-in-w

4
  • damned, this batch is a crap ! it was probably acceptable in 1983, but now... seriously ! thanks
    – poussma
    Feb 19, 2014 at 8:52
  • @ZNK-M hats's why they invented Powershell ;)
    – Dan
    Feb 19, 2014 at 8:57
  • @Dan PowerShell... hum... maybe the biggest revolution since the Nokia 3310... anyway, thanks
    – poussma
    Feb 19, 2014 at 9:04
  • @ZNK-M Powershell is fantastic, by the way.
    – Dan
    Feb 19, 2014 at 10:20

You must log in to answer this question.

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