In one of the tutorial (
CreateWindows
Service in C#) I explained how to created windows service along with the
steps for creating a setup project to install/uninstall the service. But it's not
that you always need to create a setup project to install/uninstall the service.This
can be easily achieved using the
InstallUtil command.
When using this command installation is done in a transactioned way: i.e. if any
one of the assembly fail to install, installations of all the assemblies will be
rolled back. Uninstall is not transactioned.
C:\Windows\Microsoft.NET\Framework\v4.0.30319
Note: Chose the.NET framework you are
using(I am using .NET framework 4.0 as depicted by v4.0.30319).
Skip step 1 if using the visual studio command prompt
Step: 2 Run the
installutil command without any switch.
C:\Windows\Microsoft.NET\Framework\v4.0.30319>InstallUtil
"ServiceName"
Step: 3 Navigate to Services using (run
-> services.msc), search for your service and start it.
Again to uninstall the service, using the command mentioned in step 2 with /u switch.
C:\Windows\Microsoft.NET\Framework\v4.0.30319>InstallUtil /u
"ServiceName"