Installing Windows Services during runtime

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
[1141 byte] By [DLSeth] at [2007-12-16]
# 1
Why carn't you use the installutil at runtime. I have done this before for another app where I would execute the process and redirect the console output so that the user does not see the console running.
Mykre at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 2
Mykre wrote:
Why carn't you use the installutil at runtime. I have done this before for another app where I would execute the process and redirect the console output so that the user does not see the console running.

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.
DLSeth at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 3
remember that a user must have the install util (installutil.exe) as it is part of the framework, so this being the case you would not have to distribute.

Mykre
www.ircomm.net
Managed DirectX and Game Programming Resources

Mykre at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 4
You can use the WIN32 API calls from C# to do this.
Take a look at the CreateService Win32 API function.

Regards,
Vikram

Vikram at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 5
Vikram wrote:
You can use the WIN32 API calls from C# to do this.
Take a look at the CreateService Win32 API function.

Regards,
Vikram


Not exactly what I was looking for, but it works good for me, thank you!
DLSeth at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...