In your installer class of the service itself, use the event AfterInstall to start the service. After setup has finished, the service will start.
public ProjectInstaller() { InitializeComponent(); AfterInstall += new InstallEventHandler(ProjectInstaller_AfterInstall); } void ProjectInstaller_AfterInstall(object sender, InstallEventArgs e) { System.ServiceProcess.ServiceController sc = new System.ServiceProcess.ServiceController(serviceInstaller.ServiceName); sc.Start(); }
Also have a look at this Source.
Comments