using System; using System.Collections; using System.ComponentModel; using System.ServiceProcess; namespace HeuristicLab.Clients.Hive.SlaveCore.SlaveWindowsService { [RunInstaller(true)] public partial class ProjectInstaller : System.Configuration.Install.Installer { public ProjectInstaller() { InitializeComponent(); } protected override void OnAfterInstall(IDictionary savedState) { base.OnAfterInstall(savedState); //try to start the service after installation using (var serviceController = new ServiceController(this.serviceInstaller1.ServiceName, Environment.MachineName)) { try { serviceController.Start(); } catch { } } } } }