@echo off
@setlocal enableextensions
@cd /d "%~dp0"
set HOME_DIR=%cd%
set EXECUTABLE_PATH=%cd%\start_application.bat
set SERVICE_NAME=ABS_UHFConcentrator
set SERVICE_DESCRIPTION=ABS_UHFConcentrator_Service

goto check_Permissions

:check_Permissions
    REM echo Administrative permissions required. Detecting permissions...

    net session >nul 2>&1
    if %errorLevel% == 0 (
			echo Installing %SERVICE_NAME% Service...
			nssm.exe install %SERVICE_NAME% %EXECUTABLE_PATH%
			nssm.exe set %SERVICE_NAME% AppDirectory %HOME_DIR%
			nssm.exe set %SERVICE_NAME% DisplayName %SERVICE_NAME%
			nssm.exe set %SERVICE_NAME% Description %SERVICE_DESCRIPTION%
			nssm.exe set %SERVICE_NAME% Start SERVICE_DEMAND_START
			echo SUCCESS!
    ) else (
			echo ERROR: You need administrator privileges in order to install %SERVICE_NAME% service!
    )
pause