@echo off
setlocal
cd /d "%~dp0"
net session >nul 2>&1
if %errorlevel% neq 0 (
  echo Requesting administrator rights...
  powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
  exit /b
)
echo Cleanup leftover WSL distro, then continue install (step 3)...
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
  "wsl.exe --shutdown; Start-Sleep 2; wsl.exe --unregister Ubuntu-24.04 2>$null; if (Test-Path $env:LOCALAPPDATA\essence-wsl) { Remove-Item -Recurse -Force $env:LOCALAPPDATA\essence-wsl }; Write-Host 'cleaned. running install-win11.ps1'"
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0install-win11.ps1"
echo.
pause
endlocal
