WiX:如何立即重新启动 explorer.exe? [英] WiX: How to restart the explorer.exe immediately?

查看:40
本文介绍了WiX:如何立即重新启动 explorer.exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是软件打包的初学者.我正在使用 cpack + Wix.我试图找到关于 util:RestartResource 的有用信息或好的文档,但找不到任何关于我的问题的 awnser.

I am a beginner in case of packaging of software. I am using cpack + Wix. I tried to find helpful information or a good documentation about util:RestartResource, but could not find any awnser to my question.

问题:我必须安装一个 ShellExtension,它需要在设置一些注册表值后重新启动 explorer.exe.因此我使用命令 (https://wixtoolset.org/文档/手册/v3/xsd/util/restartresource.html):

Issue: I have to install a ShellExtension which needs a restart of explorer.exe after setting some registry values. Because of that i use the command (https://wixtoolset.org/documentation/manual/v3/xsd/util/restartresource.html):

<util:RestartResource ProcessName="explorer.exe"/>

一切都几乎按预期工作.Explorer.exe 将按预期终止,但在用户完成安装后将触发 explorer.exe 的重新启动.这是令人不快的,因为 explorer.exe 会消失,直到用户单击安装的完成按钮.我想在设置注册表值后直接重新启动资源管理器.我知道这应该是可能的,因为如果 WiX 自己触发了 explorer.exe 的重启,它会立即执行并且不会等到安装完成.诀窍是什么?我已经尝试过 CustomActions 并将 util:RestartResource 放在 WiX-Code 的不同位置(我很绝望.).

Everything nearly works like expected. Explorer.exe will be killed as expected but the restart of the explorer.exe will be triggered after the user is finishing the installation. That is to unpleasant, because explorer.exe disappears till the user clicks the finalize button of the installation. I would like a direct restart of the explorer after the registry values was set. I know this should be possible, because if WiX is triggering a restart of the explorer.exe by himself, it will be executed immediately and does not wait till the installation was finished. What is the trick? I tried already CustomActions and placing util:RestartResource at different position of the WiX-Code (I am desperate.).

我正在分析安装日志.我意识到默认情况下,在进程开始时会调用重启管理器,并在最终对话框之前关闭自己.如果我将 ProcessName 添加到 RestartResource,它会打开另一个 Restart Manager,它在最终对话后关闭自己.需要找出如何像默认的 RestartResource 一样调用 RestartResource.

I am analyzing the logs of the installation. And i realized that by default a Restart Manager is called at the beginning of progress and closed himself before the final Dialog. If i add a ProcessName to RestartResource it opens another Restart Manager which closed himself after the final dialog. Need to find out how to call RestartResource like the default RestartResource.

我猜 util:RestartResource 有问题.目前我抓取 WiX 实现代码和 MSI 文档,通常您应该在状态InstallValidate"之前注册所有 RestartResources.而这正是 WiX 在 UtilExtension_Platform.wxi 中尝试做的:

I guess util:RestartResource is buggy. At the moment i crawl throw the WiX implementation code and MSI documentation and normally you should register all RestartResources before the state "InstallValidate". And that is exactly what WiX is trying to do in UtilExtension_Platform.wxi:

  <Fragment>
    <CustomAction Id="WixRegisterRestartResources$(var.Suffix)" BinaryKey="WixCA" DllEntry="WixRegisterRestartResources$(var.Suffix)" Execute="immediate" Return="check" SuppressModularization="yes" />

    <InstallExecuteSequence>
      <Custom Action="WixRegisterRestartResources$(var.Suffix)" Before="InstallValidate" Overridable="yes" />
    </InstallExecuteSequence>
  </Fragment>

因为在这个状态之后 MsiRestartManagerSessionKey 将被终止.并且 WiX 尝试在注册 RestartResource 的情况下使用此密钥.但是我在日志中看到的是,我的 util:RestartResource 调用将始终在InstallValidate"状态之后执行.并且此时日志已经表明,MsiRestartManagerSessionKey 已提前终止(在InstallValidate"状态之后).这是我反对 MSI 政策的观点.

Because after this state MsiRestartManagerSessionKey will be terminated. And WiX tries to use this key in case of the registration of a RestartResource. But what i see inside of the logs is, that my util:RestartResource call will always executed after the "InstallValidate" state. And the log already says at this point, that the MsiRestartManagerSessionKey was terminated earlier (after "InstallValidate" state). That is from my point of view against the MSI policy.

它不是马车.我会发布一个 awnser.

It is not buggy. I will post an awnser.

推荐答案

使用 util:RestartResource 不可能做我想做的事.因为util:RestartResource 写入安装数据库需要重启Process.(xml文件中util:RestartResource的位置对定时关机重启没有任何影响)

It is not possible to do what i want with util:RestartResource. Because util:RestartResource writes into the installation database which Process needs to be restarted. (the position of util:RestartResource inside of the xml file does not have any affect of the scheduled shutdown and restart)

存在一个 CustomAction,它在 InstallValidate" 状态之前调用 WixRegisterRestartResources(WixUtilExtension.dll 的一部分).这正是使用 MsiRestartManagerSessionKey 将进程注册到 MSI 的 RestartManager 所需要的.重新启动进程将从安装数据库中提取.MSI 的 RestartManager 在 InstallValidate 状态后关闭所有进程.遗憾的是,当 MSI 进程完全完成而不是更早时,它正在重新启动所有进程.这意味着它总是会在用户按下 FinalDialog 中的完成按钮后触发.它是不可更改的,因为这是 MSI 安装程序工作流程中的逻辑.

A CustomAction exist which is calling WixRegisterRestartResources (part of the WixUtilExtension.dll) before the "InstallValidate" state. That is exactly what is needed to register the process to the RestartManager of MSI with the MsiRestartManagerSessionKey. The restart processes will be extracted from the installation database. The RestartManager of MSI is shutting down all processes after the InstallValidate state. Sadly it is restarting all processes when the MSI process is completely finished and not earlier. That means it always will be triggered after user is pushing the Finish button in the FinalDialog. It is not changeable, because that is logic inside of the MSI Installer workflow.

我尝试实现一个自定义操作,将自己注册到 MsiRestartManagerSessionKey 并尝试在 EndDialog 之前重新启动所有进程,但是 MSI 的 RestartManager 拒绝所有此类请求(某种会话错误).这是 MSI 设计的一部分,因为 MSI 安装程序会在 InstallValidate 状态之后删除属性 MsiRestartManagerSessionKey.他们不希望您可以在 InstallValidate 状态后访问 RestartManager.

I tried to implement a custom action which register himself to the MsiRestartManagerSessionKey and try to restart all processes before the EndDialog, but the RestartManager of MSI is denying all kind of this requests (some kind of Session error). And that is part of the MSI design, because the MSI Installer is removing the property MsiRestartManagerSessionKey after the InstallValidate state. They dont want that you can access the RestartManager after the InstallValidate state.

最后,我使用 C++ 中的 CustomAction 实现了我自己的 RestartManager,后来当我意识到在 C# 中代码更干净时,我在 C# 中实现了它.您可以在这里找到一个很好的解释:http://community.bartdesmet.net/blogs/bart/archive/2006/11/12/Exploring-Windows-Vista_2700_s-Restart-Manager-in-C_2300_.aspx

At the end i was implementing my own RestartManager with a CustomAction in C++ and later when i was realizing in C# the code is more clean i implemented it in C#. A good explanation how this could work you will find here: http://community.bartdesmet.net/blogs/bart/archive/2006/11/12/Exploring-Windows-Vista_2700_s-Restart-Manager-in-C_2300_.aspx

这篇关于WiX:如何立即重新启动 explorer.exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆