@echo off
rem LockAgent one-click installer for remote employees.
rem Employee steps: 1) open this file  2) click Yes on the admin prompt. Done.

set SERVER=http://186.241.16.243:5000
set AGENTKEY=359f81c42b355bbe29433c02f78deb80fec6d444ac56d33b

rem Self-elevate: relaunch as administrator if not already.
net session >nul 2>&1
if %errorlevel% neq 0 (
    powershell -Command "Start-Process '%~f0' -Verb RunAs"
    exit /b
)

set DIR=%TEMP%\lockagent
powershell -ExecutionPolicy Bypass -Command "try { Write-Host 'Downloading agent package (62 MB, may take a few minutes)...' -ForegroundColor Cyan; & curl.exe '-f' '-#' '-S' '-L' '-o' \"$env:TEMP\agent.zip\" '%SERVER%/agent.zip'; if ($LASTEXITCODE -ne 0) { throw \"curl exit $LASTEXITCODE\" }; Write-Host 'Extracting...' -ForegroundColor Cyan; Expand-Archive \"$env:TEMP\agent.zip\" '%DIR%' -Force -ErrorAction Stop; Write-Host 'Installing service...' -ForegroundColor Cyan; & '%DIR%\install-agent.ps1' -ServerUrl '%SERVER%' -AgentKey '%AGENTKEY%' -ErrorAction Stop; Write-Host 'Done.' -ForegroundColor Green } catch { Write-Host \"FAILED: $_\" -ForegroundColor Red; exit 1 }"

echo.
if %errorlevel% equ 0 (
    echo Installed successfully. You can close this window.
) else (
    echo Install failed - please contact IT.
)
pause
