@echo off
:: ============================================================
::  DeployPro — Uninstall Windows Service
::  Requires: Run as Administrator
:: ============================================================

NET SESSION >nul 2>&1
IF %ERRORLEVEL% NEQ 0 (
    echo Requesting administrator privileges...
    powershell -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
    exit /B
)

cd /d "%~dp0"

echo.
echo  ============================================================
echo   DeployPro ^| Windows Service Uninstaller
echo  ============================================================
echo.
echo  This will stop and remove the DeployPro Windows service.
echo  Your application files, data, and backups will NOT be deleted.
echo.

choice /C YN /M "Are you sure you want to uninstall the service?"
IF %ERRORLEVEL% EQU 2 (
    echo  Cancelled.
    pause
    exit /B
)

echo.
echo  Uninstalling service...
echo.
node service\uninstall.js

IF %ERRORLEVEL% EQU 0 (
    echo.
    echo  ============================================================
    echo   DeployPro Windows Service has been removed.
    echo  ============================================================
    echo.
    echo  To reinstall, run install-service.bat
    echo  To run manually, run start.bat
    echo.
) ELSE (
    echo.
    echo  [ERROR] Uninstall encountered an issue. Check output above.
    echo  You can also stop/remove manually:
    echo    net stop DeployPro
    echo    sc delete DeployPro
    echo.
)

pause
