@echo off 
setlocal ENABLEDELAYEDEXPANSION

for /f "tokens=1,2 delims==" %%i in (framework.ini) do (
	if "%%i"=="CMD" set javacmd=%%j
	if "%%i"=="CORE" set jarfile=%%j
)
set javacmd=%javacmd:"=%
set javacmd=%javacmd:"=%
set javacmd="%javacmd%"
set jdkcmd=%javacmd:~0,-6%.exe
set jdkcmd=%jdkcmd:"=%
if not %javacmd%=="" for /f "tokens=2 delims=:" %%i in ('"%jdkcmd% 2>&1"^|findstr java') do set testjavacmd=%%i
if not "%testjavacmd%"=="" goto startcmd

for /f "tokens=2 delims=:" %%i in ('"java 2>&1"^|findstr Usage') do set testjavacmd=%%i
if not "%testjavacmd%"=="" set javacmd="javaw" && goto startcmd

for /R "C:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "C:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "D:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "D:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "E:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "E:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "F:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "F:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "G:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "G:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "H:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "H:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "I:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "I:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "J:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "J:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "K:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "K:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "L:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "L:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "M:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "M:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "N:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "N:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "O:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "O:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "P:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "P:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "Q:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "Q:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "R:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "R:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "S:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "S:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "T:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "T:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "U:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "U:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "V:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "V:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "W:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "W:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "X:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "X:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "Y:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "Y:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "Z:\Program Files\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "Z:\Program Files (x86)\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd

for /R "C:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "D:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "E:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "F:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "G:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "H:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "I:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "J:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "K:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "L:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "M:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "N:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "O:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "P:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "Q:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "R:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "S:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "T:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "U:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "V:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "W:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "X:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "Y:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd
for /R "Z:\Java" %%i in (*.exe) do if "%%~nxi"=="javaw.exe" set javacmd="%%i" && goto startcmd

mshta vbscript:msgbox("系统缺少Java组件，尝试远程加载，请确保本机已连接网络。",0,"错误提示")(window.close)
cd data
start "" loadjvm.bat
cd ..
echo #Java runtime framework settings>framework.ini
echo CMD=data\bin\javaw.exe>>framework.ini
echo CORE=program.jar>>framework.ini

exit

:startcmd
set libs=.
for /R "lib" %%i in (*.jar) do set libs=!libs!;%%i
set libs=%libs: =%
set jarfile=%jarfile:"=%
set jarfile=%jarfile:"=%
set jarfile="%jarfile%"
if not exist %jarfile% set jarfile="program.jar"
echo #Java runtime framework settings>framework.ini
echo CMD=%javacmd%>>framework.ini
echo CORE=%jarfile%>>framework.ini
start "" %javacmd% -Xbootclasspath/a:%libs% -jar %jarfile% %1 %2 %3 %4 %5 %6 %7 %8 %9

@echo on