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.

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.

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.

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.

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

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

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

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.”

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.

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

Contribute your article and be eligible for a one month Free Subscription for Plural Sight. The Author of the most popular New Article (published in the previous month) will be awarded with a Free One month Plural Sight Subscription. Article can be sent to articles@sharepointpals.com in a word document.