如何确保安装我的 msi 时 devenv.exe 没有运行
我正在为 Visual Studio 2008 编写 VSPackage,并使用 WiX 生成的 Msi 来部署它。 安装结束时,我根据需要运行“devenv.exe /setup”以使 VS 注意到我的包。 但是,如果有任何 Visual Studio 副本正在运行,此命令将不会成功。
目前,我告诉人们在安装之前必须关闭 Visual Studio 的所有副本,但我希望它万无一失。 当有人运行我的 .msi 时,如何检查是否有任何 Visual Studio (devenv.exe) 副本正在运行,并阻止他们安装我的项目?
I am writing a VSPackage for Visual Studio 2008, and am deploying it with a WiX generated Msi. As the end of the install, I am running "devenv.exe /setup" as required to get VS to notice my package. However, this command will not succeed if there are any copies of Visual Studio running.
Currently, I tell people they have to close all copies of Visual Studio before installing, but I would prefer it be foolproof. How can I check when someone runs my .msi if any copies of Visual Studio (devenv.exe) are running, and block them from installing my project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
WiX 工具集有一个 CloseApps CustomAction,可以为您关闭窗口。 不幸的是,它不会提示关闭所有应用程序的列表,但代码将是一个合理的起点。
The WiX toolset has a CloseApps CustomAction that will close windows for you. It unfortuantely does not prompt with a list to close all the applications but the code would be a reasonable place to start.
您最好的选择是遵循 Rob 的建议并组合自定义操作来检查进程是否正在运行。 我可能会做一些事情,比如查看它是否正在运行,尝试关闭,如果它仍在运行,则安排重新启动并进行 devenv 设置
通过 RunOnce 注册表项。
如果工作量太大,那么使用 Windows 命令
TASKKILL
退出应用程序将是一个丑陋的黑客行为。 虽然不是万无一失,但总比没有好。your best bet is to follow Rob's advide and put together a custom action to check if the process is running. I'd probably do something like see if it's running, try to close, if it's still running then schedule a reboot and do the devenv setup
via the RunOnce registry key.
If that's too much work then a bit of an ugly hack would be to use the windows command
TASKKILL
to exit the application. Not foolproof but it's better than nothing.您可以在项目中创建一个安装程序类并让它枚举正在运行的进程
You can create an installer class in your project and let it enumerate Running Processes
我必须使用 TASKKILL /IM devenv.exe -F 来终止进程,并且 cmd 必须以管理员身份运行
I had to use TASKKILL /IM devenv.exe -F to kill the process and cmd had to be run as administrator