I have a standard .NET windows service written in C#.
Can it install itself without using InstallUtil? Should I use the service installer class? How should I use it?
I want to be able to call the following:
MyService.exe -install
And it will have the same effect as calling:
InstallUtil MyService.exe
Take a look at the InstallHelper method of the ManagedInstaller class. You can install a service using:
This is exactly what InstallUtil does. The arguments are the same as for InstallUtil.
The benefits of this method are that it involves no messing in the registry, and it uses the same mechanism as InstallUtil.