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

 
echo **********************************************
echo.
echo   将要安装软件运行环境
echo.
echo  安装请按任意键,退出直接关闭窗口
echo.
echo **********************************************
 
pause
set CURRENT_DIR=%~dp0
rem set JAVA_HOME=%CURRENT_DIR:~0,-3%jre
rem set JRE_HOME=%CURRENT_DIR:~0,-3%jre\jre 
echo.
echo 正在安装jre,请不要执行其他操作
rem start /WAIT jre-8u144-windows-i586.exe /s INSTALLDIR=C:\Java\jre

set JAVA_HOME=%CURRENT_DIR%
echo %JAVA_HOME%
set PATH=%PATH%;%%JAVA_HOME%%bin;%%JAVA_HOME%%jre\bin
echo %PATH%
pause
set CLASSPATH=%%JAVA_HOME%%lib;%%JAVA_HOME%%lib\dt.jar;%%JAVA_HOME%%lib\tools.jar
 
set RegV=HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
 
reg add "%RegV%" /v "JAVA_HOME" /d "%JAVA_HOME%
reg add "%RegV%" /v "Path" /t REG_EXPAND_SZ /d "%PATH%"
reg add "%RegV%" /v "CLASSPATH" /d "%CLASSPATH%"
mshta vbscript:msgbox("Java环境已成功注册!",64,"成功")(window.close)
 
exit