且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在安装后立即启动 .NET Windows 服务?

更新时间:2023-02-02 19:43:30

您可以在服务可执行文件中执行所有这些操作,以响应从 InstallUtil 进程触发的事件.覆盖 OnAfterInstall 事件以使用 ServiceController 类来启动服务.

You can do this all from within your service executable in response to events fired from the InstallUtil process. Override the OnAfterInstall event to use a ServiceController class to start the service.

http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller.aspx