Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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"
share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.