How to automatically start your service after install?
Add the following class to your project.
using System.ServiceProcess;
class ServInstaller : ServiceInstaller
{
protected override void OnCommitted(System.Collections.IDictionary savedState)
{
ServiceController sc = new ServiceController("YourServiceNameGoesHere");
sc.Start();
}
}
The Setup Project will pick up the class and run your service after the installer finishes.
Small addition to accepted answer:
You can also fetch the service name like this - avoiding any problems if service name is changed in the future:
protected override void OnCommitted(System.Collections.IDictionary savedState)
{
new ServiceController(serviceInstaller1.ServiceName).Start();
}
(Every Installer has a ServiceProcessInstaller and a ServiceInstaller. Here the ServiceInstaller is called serviceInstaller1.)