How to automatically start your service after install?

前端 未结 7 1218
小蘑菇
小蘑菇 2020-12-05 01:50

How do you automatically start a service after running an install from a Visual Studio Setup Project?

I just figured this one out and thought I would share the answe

相关标签:
7条回答
  • 2020-12-05 02:32

    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.)

    0 讨论(0)
提交回复
热议问题