[RunInstaller(true)] public partial class ProjectInstaller : System.Configuration.Install.Installer { public ProjectInstaller() { InitializeComponent(); this.Committed += new InstallEventHandler(ProjectInstaller_Committed); } /// <summary> /// 安装完成后自启动服务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ProjectInstaller_Committed(object sender, InstallEventArgs e) { ServiceController controller1 = new ServiceController("Service1"); controller1.Start(); } }