新建记事本 改后缀 *.bat
复制下内容
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exitcd /d "%~dp0"@echo offecho 请输入jdk安装目录set /p answer= wmic ENVIRONMENT create name="JAVA_HOME",username="<system>",VariableValue="%answer%"wmic ENVIRONMENT create name="CLASSPATH",username="<system>",VariableValue=".;%%JAVA_HOME%%\lib;%%JAVA_HOME%%\lib\tools.jar"wmic ENVIRONMENT where "name='PATH' and username='<system>'" set VariableValue="%path%;%%JAVA_HOME%%\bin;%%JAVA_HOME%%\jre\bin;"echo 设置完成 按下任意键退出pause