How to Manually Install/uninstall Windows Services

Ahamed Fazil Buhari
 
Senior Developer
August 14, 2017
 
Rate this article
 
Views
4682

Hello everyone, this article just a continuation of my previous article. Here we can see how to Install and uninstall your windows service. I am just taking the simple Windows service for this example. First let me show you the error we get if we straight away go and deploy the solution and double click on the service.exe file available in project/bin/debug folder.

clip_image002

We will get the same error when we press F5 from Visual Studio. So before installing, if you think its your final release then you can build the solution using “Release” mode. You can find the difference between Debug and Release mode in the Internet.

clip_image004

First thing we need to do is, add Installer to our Windows Service Project. Open your <service>.cs and in the design view, just right click and select Installer.

clip_image006

You will get two default Installer (ServiceProcessInstaller and ServiceInstaller) and changer their properties like the service name, the account which will run the service and so on.

clip_image007

Just build the solution and make sure it is in ‘Release’ mode.

clip_image009

Then go to our solution path in windows explorer and go to bin/release folder. There you can find the <service>.exe file

clip_image011

Now open your Developer command Prompt for Visual Studio and run it in administrator mode.

clip_image013

Now just navigate to the location where your <service>.exe resides. And this part is important, we are going to install it manually and you find the command for that,

Installutil <service>.exe

Once the service is installed successfully you can see that “The commit phase completed successfully.”

clip_image015

To cross check whether your windows service is installed correctly. Just go to run and type “services.msc” and press enter. Here we need to start the service manually, so just click on start.

clip_image016

And to uninstall the service, just use the below command and its pretty simple.

Installutil /u <service>.exe

clip_image018

 

Happy Coding

Ahamed

Author Info

Ahamed Fazil Buhari
 
Senior Developer
 
Rate this article
 
Ahamed is a Senior Developer and he has very good experience in the field of Microsoft Technologies, especially SharePoint, Azure, M365, SPFx, .NET and client side scripting - JavaScript, TypeScript, ...read more
 

Leave a comment