Share via


Installing a Managed Service with a Custom Name (Part 4 of 4) [Robert Villahermosa]

Bringing it all together

Ok, that’s it for the explanation – let’s see how to actually run all this and watch it work.

Here are the steps to follow:

1.) Create a simple service that we want to install

2.) Create a ProjectInstaller class specifying some defaults and handing custom install/uninstall events

3.) Compile this service, run “csc MyService.cs” (this will generate MyService.exe)

4.) Install this service, run “InstallUtil.exe MyService.exe”

a. You’ll get prompted for a service name here

b. You’ll see this name gets persisted to a file Service.config

5.) Check to see if the service installed (run services.msc or check the registry under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services)

6.) To uninstall the service, run “InstallUtil.exe MyService.exe /u”

That’s it! As you can see, you can now install/uninstall a service with the name of your choice. Now go add something useful to this service so it makes you happy. The code is listed here so you can build this without copying/pasting.

 

<editorial notes>
The full article (all four parts) can be found here. How do you like this week's article? Do you prefer the shorter posts or these longer articles? Let us know!
</editorial notes>