@echo off
setlocal
set "JAR=%~dp0Workstation4ad3s-3.0.24.jar"
echo Starting Workstation4ad3s...
echo Please wait up to 1 minute for the application to open.
echo.
REM 1) Bundled JRE
if exist "%~dp0jre\bin\java.exe" (
    "%~dp0jre\bin\java.exe" -jar "%JAR%"
    goto :eof
)
REM 2) JAVA_HOME
if defined JAVA_HOME if exist "%JAVA_HOME%\bin\java.exe" (
    "%JAVA_HOME%\bin\java.exe" -jar "%JAR%"
    goto :eof
)
REM 3) PATH
where java >nul 2>&1
if not errorlevel 1 (
    java -jar "%JAR%"
    goto :eof
)
REM 4) Find java.exe anywhere under Program Files
for /f "delims=" %%J in ('dir /b /s "C:\Program Files\java.exe" 2^>nul') do (
    "%%J" -jar "%JAR%"
    goto :eof
)
echo ============================================================
echo  Java not found.
echo  Put JRE into jre\ folder next to this script.
echo  See README.md for details.
echo ============================================================
pause
exit /b 1