@echo off

REM Set variables
SET CURRENT_DIR=%~dp0
SET SERVICE_NAME=UPScom

REM Check If Service Exists
sc.exe query %SERVICE_NAME% > nul
if errorlevel 1 goto :EXIT
goto :DELETE_INSTALLED_SERVICE

REM Delete the installed service
:DELETE_INSTALLED_SERVICE
echo Service '%SERVICE_NAME%' installed. Service will be stopped...
sc.exe stop %SERVICE_NAME% > nul
REM if errorlevel 1 goto :ERROR
echo Service '%SERVICE_NAME%' will be deleted...
sc.exe delete %SERVICE_NAME%
if errorlevel 1 goto :ERROR
goto :EXIT
:ERROR
echo An error occurred during the installation (%errorlevel%).

:EXIT
pause
