Windows下Android环境变量设置bat批处理
2017-06-24 本文已影响94人
JumboWu
Android开发中经常需要设置环境变量,写个bat批处理方便配置,保存下改为SetEnv.bat
运行即可。参数根据你自己的路径填写。
@echo 设置环境变量 By Jumbo
set regpath=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
echo 添加Android环境变量
set ANDROID_SDK_ROOT=E:\android\android-sdk
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v ANDROID_SDK_ROOT >nul 2>nul||goto :A
:A
reg add "%regpath%" /v ANDROID_SDK_ROOT /d %ANDROID_SDK_ROOT% /f
set ANDROID_SDK_HOME=E:\android\android-sdk
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v ANDROID_SDK_HOME >nul 2>nul||goto :B
:B
reg add "%regpath%" /v ANDROID_SDK_HOME /d %ANDROID_SDK_HOME% /f
set ANDROID_HOME=E:\android\android-sdk
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v ANDROID_HOME >nul 2>nul||goto :C
:C
reg add "%regpath%" /v ANDROID_HOME /d %ANDROID_HOME% /f
echo 添加Ant环境变量
set ANT_HOME=E:\apache-ant-1.9.4
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v ANT_HOME >nul 2>nul||goto :D
:D
reg add "%regpath%" /v ANT_HOME /d %ANT_HOME% /f
set UNITY_PATH="E:\Program Files (x86)\Unity\Editor"
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v UNITY_PATH >nul 2>nul||goto :E
:E
reg add "%regpath%" /v UNITY_PATH /d %UNITY_PATH% /f
echo 添加Java环境变量
set JAVA_HOME="E:\Program Files (x86)\Java\jdk1.8.0_45"
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v JAVA_HOME >nul 2>nul||goto :F
:F
reg add "%regpath%" /v JAVA_HOME /d %JAVA_HOME% /f
echo 修改Path
set PATH = %PATH%;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin;%ANT_HOME%\bin;%ANDROID_SDK_HOME%\platform-tools;%ANDROID_SDK_HOME%\tools;
echo 修改ClassPath
set CLASSPATH = %CLASSPATH%;.;%JAVA_HOME%\libdt.jar;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\annotations.jar;
echo 完成
pause