DEV Community

Cover image for How to Install or Uninstall a Windows Service
twostepdevelopers
twostepdevelopers

Posted on

How to Install or Uninstall a Windows Service

In this article. I will show how to install or uninstall a Windows Service. this Service is written in .NET using C#.
To install or uninstall Windows Service use the utility InstallUtil.exe.

Follow the steps .
Step 1 : Open the Command Prompt window. (as Administrator)
Press Windows+R to open the “Run” box. Type “cmd” into
the box and then press Ctrl+Shift+Enter to run the
command as an administrator.
Alt Text

Step 2 : Open InstallUtil.exe in the directory for Framework 2.0 (it depends on you in which version you want to install).I will install in v4.0
the path is C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\
Alt Text

Note: The path will be different for different versions of .NET Framework. You can see on this path (C:\Windows\Microsoft.NET\Framework) or search on your machine where InstallUtil.exe is stored.

Step 3 :.NET service runs as a command (specify the full path to your service such as (service location C:\Debug\yourServiceName.exe)
type command in cmd InstallUtil.exe C:\Debug\yourServiceName.exe Press enter key as you can see here.
Alt Text

Step 4: If you want to see service is where it is installed.
press window+R and type in run like services.msc
Alt Text
as you can see where service is installed . just click to start your service.Now it is ready to work. :)
Alt Text

Step 5: To uninstall service. just type simple command in prompt
just add ‘/u’ between installutil.exe and the path as in the following:
InstallUtil.exe /u C:\Debug\yourServiceName.exe
Alt Text

I hope this is helpful to you .If you like my post Please follow me on Instagram @twostepdevelopers and share your feedback.

Discussion (0)