安装前停止服务

发布于 2024-11-17 20:44:23 字数 259 浏览 3 评论 0原文

我编写了一个使用 Visual Studio 2010 安装项目安装的应用程序。作为安装的一部分,我的应用程序安装并启动 Windows 服务。那里没有问题。

当我发布应用程序的新版本时,安装程​​序会覆盖应用程序文件夹的内容。不幸的是,它无法覆盖该服务,因为它已经在运行。

如何在 MSI 开始复制文件之前停止该服务?我正在考虑一个自定义引导程序(安装程序先决条件),它不会安装,但会删除该服务。或者我可以在安装前使用 Orca 添加一个操作吗?或者你知道另一种方法吗?

I wrote an application that installs using the Visual Studio 2010 Setup Project. As part of its installation, my application installs and starts a Windows Service. No problems there.

When I release a new version of the application, the installer overwrites the contents of the application folder. Unfortunately, it cannot overwrite the service as it is already running.

How can I stop the service before the MSI starts copying files? I'm considering a custom bootstrapper (installer prerequisit) that doesn't install, but removes the service. Or can I use Orca to add an action before installation? Or do you know another way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

走过海棠暮 2024-11-24 20:44:23

通常这是通过服务控制操作来完成的。基本上,您需要设置停止和删除标志才能卸载。

另一种方法是使用 ServiceInstaller.Uninstall 在自定义操作中停止并删除服务。

如果您想避免出现文件正在使用对话框,您可以尝试以下方法:
从安装程序类停止 Windows 服务时出现问题。事件触发得太晚了

Usually this is done through service control operations. Basically, you need the Stop and Delete flags set for uninstall.

Another approach would be to use ServiceInstaller.Uninstall in a custom action to stop and remove the service.

If you want to avoid the files in use dialog, you can try this approach:
Problem stopping Windows Service from Installer Class. Events fire too late

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文