Suppose an executable named ConsoleOrService.exe is written in C#. It currently is a hybrid. I can just start it on the command line, or I can install it using the .Net’s installutil ConsoleOrService.exe and then start the service. I would like a third option: running it on the command line like so: ConsoleOrService.exe --install and have it do all of the work.
- Is this possible?
- Is this hard?
- How can I get started?
Thank you, and let me know if there are questions please.
It’s actually quite simple. I’ve used it in many of my own services (in fact, ALL of my services are capable of doing their own install/uninstall. I control it with a command-line switch, such as
/installor/uninstall.The installation is performed like this:
The uninstallation is the same, except that you call
ti.Uninstall(null);instead ofti.Install(...);.My
MyServiceInstalleris a class that inherits from theSystem.Configuration.Install.Installerclass (as you would normally have in a service).