Command Line

Make sure you open up Command Prompt and run in administrator mode.

set path=C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
InstallUtil.exe D:\folder\MyApp.exe

App should now appear in Services.

InstallUtil.exe /u D:\folder\MyApp.exe

App should now be removed from Services.

Batch File

InstallMyAppAsService.bat

@ECHO OFF

IF "%1" EQU "Quiet" GOTO INSTALL

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

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

goto end

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

echo Installing the MyApp windows service...
echo ---------------------------------------------------

InstallUtil.exe D:\folder\MyApp.exe

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

:end

IF "%1" NEQ "Quiet" PAUSE

UninstallMyAppAsService.bat

@ECHO OFF

IF "%1" EQU "Quiet" GOTO REMOVE

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

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

goto end

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

echo Uninstalling MyApp windows service...
echo ---------------------------------------------------

InstallUtil.exe /u D:\folder\MyApp.exe

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

:end

IF "%1" NEQ "Quiet" PAUSE

Sources:

https://docs.microsoft.com/en-us/dotnet/framework/tools/installutil-exe-installer-tool

Last modified: August 14, 2019

Author

Comments

Write a Reply or Comment