How to install and uninstall a window service created in C#

Posted on Posted in Microsoft, Window Service

First make sure you have all files you need to install a Windows Service (dll, sql, anything else needed)

To install a Windows service use the command below

installutil MyWindowService.exe

First open Developer Command Prompt for Visual Studio and
then navigate to directory where files are located….

In my case I have bin directory at the following location

C:\Development\ABC \MyProject\bin\Debug>installutil MyWindowService.exe

After hitting enter will install MyWindowService. We can
check this by going to Control Panel> Administrator Tools>Services and
look for your service name

We can either start this manually or set it to run
automatically

To uninstall a windows service do the following

C:\Development\ABC \MyProject\bin\Debug>installutil
/u MyWindowService.exe

Same directory except /u once done window service will be
removed

In some case it might not remove a window service and you
still see same window service in services but disabled

To remove that just get rid of Microsoft Management Console
(MMC) .

To ensure all instances are closed, run taskkill /F /IM mmc.exe in command prompt and when you
restart/open services again your service will be gone