@echo on echo Setting JAVA_HOME set JAVA_HOME=D:\dev\tools\Java\jdk1.7.0_07 echo setting PATH set PATH=%JAVA_HOME%\bin;%PATH% wmic ENVIRONMENT where "name=‘JAVA_HOME‘" delete wmic ENVIRONMENT create name="JAVA_HOME",username="<system>",VariableValue="%JAVA_HOME%" echo Display java version java -version pause