Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

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

The answer is no, but there are several workarounds discussed here:

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

Your Answer


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.