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"
Best Answer
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