@echo off&setlocal enabledelayedexpansion
cls
@echo "This script is used to registe envionment variables......"
@echo.
@echo.
@echo.
set var=%~dp0
set var=%var:~,-1%
@echo "registe start......"
set JAVA_HOME_=%var%/Java/jdk-9.0.4
set ANT_HOME_=%var%/apache-ant-1.9.7
set CXF_HOME_=%var%/apache-cxf-3.2.1
set MAVEN_HOME_=%var%/apache-maven-3.5.2
set TOMCAT_HOME_=%var%/apache-tomcat-9.0.1
setx "JAVA_HOME" "%JAVA_HOME_%" /m
setx "ANT_HOME" "%ANT_HOME_%" /m
setx "CXF_HOME" "%CXF_HOME_%" /m
setx "MAVEN_HOME" "%MAVEN_HOME_%" /m
setx "TOMCAT_HOME" "%TOMCAT_HOME_%" /m
setx "PATH" "%JAVA_HOME_%/bin;%ANT_HOME_%/bin;%CXF_HOME_%/bin;%MAVEN_HOME_%/bin;%TOMCAT_HOME_%/bin;%PATH%" /m
@echo "registe end......"
pause
exit
::添加java环境变量
echo 添加java环境变量
set regpath=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
set envName_java=JAVA_HOME
set envValue_java=c:\java\jdk
reg add "%regpath%" /v %envName_java% /d %envValue_java% /f
pause
::删除java环境变量
echo 删除java环境变量
set regpath=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
set envName_java=JAVA_HOME
reg delete "%regpath%" /v "%envName_java%" /f
pause