@REM BATCH FILE
@ECHO off
rem =========================================================
rem Declare global variables here.
rem =========================================================
set INSTALL_EXE=C:\Windows\Microsoft.NET\Framework\v2.0.50727
set SERVICE_EXE="Prog.exe"
set SERVICE_SID="Prog"
rem =========================================================
rem Install / Uninstall Windows Service
rem =========================================================
echo Checking system service: [%SERVICE_SID%]
sc query %SERVICE_SID% | findstr /c:"RUNNING" /c:"STOPPED"
if "%ERRORLEVEL%"=="0" goto UninstallPrompt
rem ====== Install Service ===========================
echo Service not installed. Install and start service?
set /P c=Answer [y/n]?
if /I "%c%" EQU "Y" goto :Install
goto:eof
:Install
%INSTALL_EXE%\InstallUtil.exe %SERVICE_EXE%
net start %SERVICE_SID%
goto:eof
rem ====== Uninstall Service ========================
:UninstallPrompt
echo Service installed. Stop and uninstall service?
set /P c=Answer [y/n]?
if /I "%c%" EQU "Y" goto :Uninstall
goto:eof
:Uninstall
net stop %SERVICE_SID%
%INSTALL_EXE%\InstallUtil.exe -u %SERVICE_EXE%
goto:eof