Hi all,
My installer program doesn't suppport installing services but I can run a program/command line etc so my question is how can I install a Windows Service and add 2 dependencies using the command line? The program is a .Net 2.0 app.
Thanks
Hi all,
My installer program doesn't suppport installing services but I can run a program/command line etc so my question is how can I install a Windows Service and add 2 dependencies using the command line? The program is a .Net 2.0 app.
Thanks
You can write a self-installing service and have it set a list of services your service depends on when the installer is executed.
Basic steps:
edit: forgot to mention that you can use e.g. Installutil.exe to invoke the installer.
[RunInstaller(true)]
public class MyServiceInstaller : Installer
{
public MyServiceInstaller()
{
using ( ServiceProcessInstaller procInstaller=new ServiceProcessInstaller() ) {
procInstaller.Account = ServiceAccount.LocalSystem;
using ( ServiceInstaller installer=new ServiceInstaller() ) {
installer.StartType = ServiceStartMode.Automatic;
installer.ServiceName = "FooService";
installer.DisplayName = "serves a lot of foo.";
installer.ServicesDependedOn = new string [] { "CLIPBOOK" };
this.Installers.Add(procInstaller);
this.Installers.Add(installer);
}
}
}
}
One method that's available is sc.exe. It allows you to install and control services from a command prompt. Here is an older article covering it's use. It does allow you to specify dependencies as well.
Take a look at the article for the sc create portion for what you need.
There is a dynamic installer project on codeproject that I have found useful for services installation, in general.
Visual Studio Setup/Deployment projects work for this. They are not the best installer engine, but they work fine for simple scenarios.