[No0000111]java9环境变量配置bat

保存成bat(utf-8 无签名 编码)

右键以管理员权限运行

修改JAVAINSTALLPATH 为JAVA SDK 安装目录(默认用C:\PROGRAM FILES\JAVA\)即可;

只在 用户变量下 创建,会事先保存好用户原有的“JAVA_HOME,JRE_HOME,PATH,CLASSPATH”等变量到"OlD-JAVA_HOME,JRE_HOME,PATH,CLASSPATH.TXT"(按JAVA_HOME,JRE_HOME,PATH,CLASSPATH顺序保存),然后删除用户JAVA_HOME,JRE_HOME,PATH,CLASSPATH”变量,并创建JAVA SDK变量。之后会打开环境变量设置窗口和"OlD-JAVA_HOME,JRE_HOME,PATH,CLASSPATH.TXT",按需补充原有变量值。

CD  /D  "%~dp0"
::PAUSE
SET JAVAINSTALLPATH=C:\PROGRAM FILES\JAVA\

START SYSTEMPROPERTIESCOMPUTERNAME.EXE

DEL "OlD-JAVA_HOME,JRE_HOME,PATH,CLASSPATH.TXT"

WMIC ENVIRONMENT WHERE "NAME='JAVA_HOME' AND USERNAME LIKE '%%%USERNAME%'" GET VARIABLEVALUE >> "OlD-JAVA_HOME,JRE_HOME,PATH,CLASSPATH.TXT"
WMIC ENVIRONMENT WHERE "NAME='JRE_HOME' AND USERNAME LIKE '%%%USERNAME%'" GET VARIABLEVALUE >> "OlD-JAVA_HOME,JRE_HOME,PATH,CLASSPATH.TXT"
WMIC ENVIRONMENT WHERE "NAME='PATH' AND USERNAME LIKE '%%%USERNAME%'" GET VARIABLEVALUE >> "OlD-JAVA_HOME,JRE_HOME,PATH,CLASSPATH.TXT"
WMIC ENVIRONMENT WHERE "NAME='CLASSPATH' AND USERNAME LIKE '%%%USERNAME%'" GET VARIABLEVALUE >> "OlD-JAVA_HOME,JRE_HOME,PATH,CLASSPATH.TXT"

::PAUSE

WMIC ENVIRONMENT WHERE "NAME='JAVA_HOME' AND USERNAME LIKE '%%%USERNAME%'" DELETE
WMIC ENVIRONMENT WHERE "NAME='JRE_HOME' AND USERNAME LIKE '%%%USERNAME%'" DELETE
WMIC ENVIRONMENT WHERE "NAME='PATH' AND USERNAME LIKE '%%%USERNAME%'" DELETE
WMIC ENVIRONMENT WHERE "NAME='CLASSPATH' AND USERNAME LIKE '%%%USERNAME%'" DELETE

::PAUSE

WMIC ENVIRONMENT CREATE NAME="JAVA_HOME",USERNAME="%USERNAME%",VARIABLEVALUE="'%JAVAINSTALLPATH%JDK-9'"
WMIC ENVIRONMENT CREATE NAME="JRE_HOME", USERNAME="%USERNAME%",VARIABLEVALUE="'%JAVAINSTALLPATH%JRE-9'"
WMIC ENVIRONMENT CREATE NAME="PATH",     USERNAME="%USERNAME%",VARIABLEVALUE=".;%%JAVA_HOME%%\BIN;%%JRE_HOME%%\BIN"
WMIC ENVIRONMENT CREATE NAME="CLASSPATH",USERNAME="%USERNAME%",VARIABLEVALUE=".;%%JAVA_HOME%%\LIB;%%JRE_HOME%%\LIB"

START "OLD-JAVA_HOME,JRE_HOME,PATH,CLASSPATH.TXT"

PAUSE

 

posted @ 2017-10-27 10:55  CharyGao  阅读(698)  评论(0编辑  收藏  举报