码迷,mamicode.com
首页 > 编程语言 > 详细

java9环境变量配置bat

时间:2017-10-27 11:30:10      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:blog   环境   ble   value   log   user   sys   color   span   

保存成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

 

java9环境变量配置bat

标签:blog   环境   ble   value   log   user   sys   color   span   

原文地址:http://www.cnblogs.com/Chary/p/7742098.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!