private void Installer_Committed(Object sender, InstallEventArgs e) { //auto start the service once the installation is finished var controller = new ServiceController(InstallTimeConfigurationManager.GetConfigurationValue("SystemServiceName")); controller.Start(); }
public HardWorkingServiceInstaller() : base() { var serviceProcessInstaller = new ServiceProcessInstaller(); var serviceInstaller = new ServiceInstaller(); //Service Account Information serviceProcessInstaller.Account = ServiceAccount.LocalSystem; serviceProcessInstaller.Username = null; serviceProcessInstaller.Password = null; //Service Information serviceInstaller.DisplayName = InstallTimeConfigurationManager.GetConfigurationValue("ServiceDisplayName"); serviceInstaller.Description = InstallTimeConfigurationManager.GetConfigurationValue("ServiceDescription"); serviceInstaller.StartType = ServiceStartMode.Automatic; serviceInstaller.DelayedAutoStart = true; //This must be identical to the WindowsService.ServiceBase name //set in the constructor of WindowsService.cs serviceInstaller.ServiceName = InstallTimeConfigurationManager.GetConfigurationValue("SystemServiceName"); this.Installers.Add(serviceProcessInstaller); this.Installers.Add(serviceInstaller); this.Committed += Installer_Committed; }