@echo off
setlocal
title Elm City Computing - Server Updater
set "SCRIPT=%~dp0ElmCityServerUpdater.ps1"

echo.
echo ============================================================
echo  Elm City Computing - Server Updater
echo ============================================================
echo.
if not exist "%SCRIPT%" (
    echo ERROR: ElmCityServerUpdater.ps1 was not found.
    echo Place this launcher in the same folder as the PowerShell script.
    pause
    exit /b 1
)

fltmc >nul 2>&1
if errorlevel 1 (
    echo Requesting administrator privileges...
    set "ECC_LAUNCHER=%~f0"
    powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath $env:ComSpec -ArgumentList ('/c ""' + $env:ECC_LAUNCHER + '""') -Verb RunAs"
    exit /b
)

echo 1. Audit only (recommended first run)
echo 2. Audit + update Samsung Magician
echo 3. Audit + install Windows updates
echo 4. Audit + Windows updates + Samsung Magician
echo 5. Cancel
echo.
choice /c 12345 /n /m "Choose 1-5: "
set "CHOICE=%errorlevel%"
if "%CHOICE%"=="5" exit /b 0
if "%CHOICE%"=="4" set "FLAGS=-InstallWindowsUpdates -UpdateSamsungMagician"
if "%CHOICE%"=="3" set "FLAGS=-InstallWindowsUpdates"
if "%CHOICE%"=="2" set "FLAGS=-UpdateSamsungMagician"
if "%CHOICE%"=="1" set "FLAGS="
echo.
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT%" %FLAGS%
set "RESULT=%errorlevel%"
echo.
echo Finished. Exit code: %RESULT%
pause
exit /b %RESULT%
