bat文件设置环境变量

::获取管理员权限

@echo off
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"

@echo off
:: 设置JDK环境变量JAVA_HOME
wmic ENVIRONMENT create name="JAVA_HOME",username="",VariableValue="%~dp0jdk1.7.0_79"
echo %JAVA_HOME%
pause

你可能感兴趣的:(bat文件设置环境变量)