How to Install Or Uninstall .NET Windows Service Using C#


This article explains how to install or uninstall a .NET Windows Service using C#. This article starts with an introduction of installing and uninstalling a .NET Windows Service using C#.

To install or uninstall a Windows Service (that was created using the .NET Framework) use the utility InstallUtil.exe. This tool can be found in the following path.

Step 1: Open a Command Prompt window.

Open the InstallUtil.exe directory for the Framework 2.0; the path is “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\”.

Command prompt window

Step 2: Then use the .NET service run command similar to this (specify the full path to your service):

“InstallUtil.exe  C:\DemoService\DemoWindowsService.exe”

service path

Step 3: And if you want to uninstall a Windows Service then you just add "/u" between installutil.exe and the path as in the following:

“InstallUtil.exe  /u  C:\DemoService\DemoWindowsService.exe”

uninstall windows service

Final Step

To check the service after the install you just open local services and find your service there.

local service

This article explained how to install and uninstall a .NET Windows Service using C# using InstallUtil.exe.