@echo off
setlocal

:: Ensure running as admin
net session >nul 2>&1
if %errorLevel% neq 0 (
    echo Requesting administrative privileges...
    powershell -Command "Start-Process '%~f0' -Verb RunAs"
    exit /b
)

set SERVICE_NAME=SalesSummaryWorker
set DISPLAY_NAME=Sales Summary Worker

:: Get current directory (where bat is located)
set BASE_DIR=%~dp0
set EXE_PATH=%BASE_DIR%SalesSummaryWorker.exe

echo Installing service from:
echo %EXE_PATH%

sc.exe create %SERVICE_NAME% binPath= "\"%EXE_PATH%\"" start= auto DisplayName= "%DISPLAY_NAME%"

sc.exe start %SERVICE_NAME%

echo Done.
pause