Scripts for installing and uninstalling service host on Windows machine.

Need to reinstall every time the service is modified and recompiled.

Make sure ServiceHost is setup atc:\AbcService\AbcServiceHost.exe

InstallService.bat

@ECHO OFF

IF "%1" EQU "Quiet" GOTO INSTALL

SET /P userInput=Install AbcService service? (Y/N): 

if "%userInput%"=="Y" goto install
if "%userInput%"=="y" goto install

goto end

:install
del *.log
set path=C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319

echo Installing the AbcService  windows  service...
echo ---------------------------------------------------

InstallUtil.exe c:\AbcService\AbcServiceHost.exe

echo ---------------------------------------------------
echo Done....

:end

IF "%1" NEQ "Quiet" PAUSE

May need to modify the app.config to point the database connection to your database.

UninstallService.bat

@ECHO OFF

IF "%1" EQU "Quiet" GOTO REMOVE

SET /P userInput=Uninstall AbcService service? (Y/N): 

if "%userInput%"=="Y" goto remove
if "%userInput%"=="y" goto remove

goto end

:remove
del *.log
set path=C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319

echo Uninstalling the AbcService  windows  service...
echo ---------------------------------------------------

InstallUtil.exe /u c:\AbcService\AbcServiceHost.exe

echo ---------------------------------------------------
echo Done....

:end

IF "%1" NEQ "Quiet" PAUSE

Note:

Once the service is installed, you don’t have to uninstall and re-install the service if you make a change to the app.config file.

Last modified: December 17, 2020

Author

Comments

Write a Reply or Comment