@echo off setlocal DisableDelayedExpansion title EnorialsHUD Setup pushd "%~dp0" if errorlevel 1 exit /b 1 if not exist "EnorialsHUD-Setup.jar" goto missing_jar set "ENORIALS_SETUP_ROOT=%~dp0" set "ENORIALS_SETUP_JAVA=" rem Prefer a bundled Java, then JAVA_HOME/PATH and sibling JDK installations. rem Only read version information; never install software or change system settings. for /f "usebackq delims=" %%J in (`powershell.exe -NoProfile -Command "$c=@((Join-Path $env:ENORIALS_SETUP_ROOT 'java/bin/java.exe')); if($env:JAVA_HOME){$c+=Join-Path $env:JAVA_HOME 'bin/java.exe'}; $found=Get-Command java.exe -CommandType Application -ErrorAction SilentlyContinue; if($found){$c+=$found[0].Source}; $roots=@(); if($env:JAVA_HOME){$roots+=Split-Path $env:JAVA_HOME}; $roots+=@((Join-Path $env:ProgramFiles 'Java'),(Join-Path $env:ProgramFiles 'Eclipse Adoptium'),(Join-Path $env:ProgramFiles 'Microsoft')); foreach($root in $roots){$c+=Get-ChildItem -LiteralPath $root -Directory -ErrorAction SilentlyContinue | ForEach-Object {Join-Path $_.FullName 'bin/java.exe'}}; foreach($j in ($c | Select-Object -Unique)){if(Test-Path -LiteralPath $j -PathType Leaf){$v=(& $j --version 2>$null | Select-Object -First 1); if($v -match '^(?:openjdk|java) (\d+)' -and [int]$Matches[1] -ge 25){Write-Output $j; exit 0}}}; exit 1"`) do set "ENORIALS_SETUP_JAVA=%%J" if not defined ENORIALS_SETUP_JAVA goto missing_java echo Java: "%ENORIALS_SETUP_JAVA%" echo. if not "%~1"=="" goto arguments "%ENORIALS_SETUP_JAVA%" -jar "EnorialsHUD-Setup.jar" gui if errorlevel 1 goto failed popd exit /b 0 :arguments "%ENORIALS_SETUP_JAVA%" -jar "EnorialsHUD-Setup.jar" %* set "ENORIALS_SETUP_RESULT=%ERRORLEVEL%" popd exit /b %ENORIALS_SETUP_RESULT% :missing_jar echo Extract the entire release ZIP first. Keep this BAT beside EnorialsHUD-Setup.jar. goto failed :missing_java echo Java 25 or newer was not found. Install Java 25 and set JAVA_HOME to its folder, echo or put a compatible Java runtime in the java folder beside this BAT. goto failed :failed echo. echo Setup could not start. No software or system settings were changed. pause popd exit /b 1