How to automatically start your service after inst

2019-01-13 14:55发布

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 answer for the general good. Answer to follow. I am open to other and better ways of doing this.

7条回答
【Aperson】
2楼-- · 2019-01-13 15:28

thanks it run OK...

private System.ServiceProcess.ServiceInstaller serviceInstaller1;

private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
    ServiceController sc = new ServiceController("YourServiceName");
    sc.Start();
}
查看更多
登录 后发表回答