@echo off
REM ============================================================
REM   אתגר העובד — התקנה (Windows)
REM   קליק ימני על הקובץ הזה  ->  "הפעל כמנהל" (Run as administrator)
REM ============================================================
setlocal

REM --- אם לא רץ כמנהל, מבקש הרשאות ומריץ מחדש ---
net session >nul 2>&1
if %errorlevel% neq 0 (
    echo מבקש הרשאות מנהל...
    powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
    exit /b
)

set "DIR=%~dp0"
set "REPO_BASE=https://install.rafaelstraus.com"

if exist "%DIR%installer.ps1" (
    REM ריצה מקומית (installer.ps1 יושב ליד install.bat)
    powershell -NoProfile -ExecutionPolicy Bypass -File "%DIR%installer.ps1" %*
) else (
    REM ריצה מהאתר (הורדת install.bat בלבד)
    powershell -NoProfile -ExecutionPolicy Bypass -Command "irm '%REPO_BASE%/installer.ps1' -OutFile '%TEMP%\installer.ps1'; & '%TEMP%\installer.ps1'"
)

echo.
pause
endlocal
