NT Service Installation
-
I've read the documentation on how to install an NT service using .NET but I'm unsure of exactly how it works. I 've created the installer object but hte documentation is unclear of what I should do in my Custom Action or even how to set one up properly. Does anyone know of a good tutorial on this? Jared jparsons@jparsons.org www.prism.gatech.edu/~gte477n
-
I've read the documentation on how to install an NT service using .NET but I'm unsure of exactly how it works. I 've created the installer object but hte documentation is unclear of what I should do in my Custom Action or even how to set one up properly. Does anyone know of a good tutorial on this? Jared jparsons@jparsons.org www.prism.gatech.edu/~gte477n
I'm actually working on an article that includes coverage of services. Here's the code I use to install a service:
[RunInstaller(true)] public class ServiceInstaller: Installer
{
private System.ServiceProcess.ServiceInstaller svcInst;
private System.ServiceProcess.ServiceProcessInstaller processInstaller;public ServiceInstaller()
{processInstaller = new System.ServiceProcess.ServiceProcessInstaller(); svcInst = new System.ServiceProcess.ServiceInstaller(); // Service will run under the system account processInstaller.Account = ServiceAccount.LocalSystem; svcInst.StartType = ServiceStartMode.Manual; // These are the other possible valuse for ServiceStartMode... // ServiceStartMode.Manual // ServiceStartMode.Automatic // ServiceStartMode.Disabled svcInst.ServiceName = "EWService"; svcInst.DisplayName="EW Sample Service"; Installers.Add(svcInst); Installers.Add(processInstaller);
}
}The code basically establishes the service's name, display name, startup, and logon. Use InstallUtil to install the service and configure it as in the preceding class. Erik Westermann Author, Learn XML In A Weekend ^ (October 2002)