Aloha,
I've been trying to install a Windows service during runtime in Visual C# without using any seperate programs like installutil.exe. The MSDN library barely gives any information on this, always referring to installutil.exe or a full MSI installer package, neither of which can be done in runtime.
I'm wondering if it's even possible to do this during runtime. Perhaps it would be better (but messier) to directly alter the registry perhaps Even so, I'd much rather prefer the cleaner was of using the proper classes and methods provided. (Even though the former might be quicker) An idea I had was to create a class with inherits from the System.Configuration.Install class, adding the ServiceProjectInstaller and ServiceInstaller to my class' Installers collection and then manually calling my class' Install function (which writelines some info and then calls base.Install ) but sadly this doesn't work.
The ServiceProcessInstaller and ServiceInstaller are both properly defined and the service successfully installs when I use installutil.exe on the resulting executable.
Thanks in advance,
DLSeth

Installing Windows Services during runtime
Azra
Take a look at the CreateService Win32 API function.
Regards,
Vikram
Kemp Brown MSFT
Not exactly what I was looking for, but it works good for me, thank you!
ooodi
Yes, I'm aware that's a possibility but I would really prefer to do this without relying on any other software. It's just a hobby project of my own that I'm working with, so neither time nor money are an issue for me so I'll happily take the hard route.
There's also the matter of distribution; If I finish and release the software under a BSD license then would I be allowed to distribute installutil.exe along with it Or am I even allowed to release a program under the BSD license which relies for a large part on installutil.exe I'm not a legal wizard, I'm a programmer.
Lastly, calling installutil.exe and hiding the output just doesn't feel like solid and clean programming to me. But that's just my humble opinion.
johnny wisconsin
MattiasO
Mykre
www.ircomm.net
Managed DirectX and Game Programming Resources