安装程序 OnCommited 问题
我稍后编写了一个安装程序,用于安装我想在安装程序完成时启动的服务。我将启动服务的代码放在 ServiceInstaller 的 OnCommited 方法中。我这样做是因为我发现很多关于该主题的搜索都是这样做的,但我记得还有其他方法可以做到这一点。
但回想起来,我不确定这是否是正确的做法。
特别是,文档说 OnCommited 在安装提交后被调用。这也算卸载吗?我不想尝试启动我正在卸载的服务!
想法?
I wrote an installer a bit back that installs a service that I wanted to start when the installer finished. I put the code to start the service in the OnCommitted method of the ServiceInstaller. I did this because a lot of searches I found on the topic did it this way, but I remember there were also other ways to do it.
In looking back though, I'm not sure if this was the right thing to do.
In particular, the docs say that OnCommitted gets called after the Commit of the installation. Does that also count for uninstalling? I wouldn't want to be trying to start a service I am uninstalling!
Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
建议的方法是使用 ServiceControl 表。基本上,您创建一个服务控制操作,告诉 Windows Installer 在安装后启动该服务。
The recommended approach is to use ServiceControl table. Basically, you create a service control operation which tells Windows Installer to start the service after it's installed.