如何在所有其他操作之前执行自定义操作(包括标准和自定义操作) [英] How to execute a custom action before all of other actions (include standard and custom actions)

查看:54
本文介绍了如何在所有其他操作之前执行自定义操作(包括标准和自定义操作)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 wix 安装程序中执行我的自定义操作,以删除之前在 InstallExecuteSequence 中编写的注册表项,然后如下所示:

 <Custom Action="RemoveExistingReristryKey" Sequence="150">未安装</Custom></InstallExecuteSequence>

运行 .msi 文件时,调用了 RemoveExistingReristryKey 函数并删除了注册表项,我可以看到日志:

...行动结束 17:12:59:CostFinalize.返回值 1.

MSI (c) (90:54) [17:12:59:596]:执行操作:RemoveExistingReristryKey行动 17:12:59:删除现有的ReristryKey.行动开始 17:12:59:RemoveExistingReristryKey.MSI (c) (90:E4) [17:12:59:616]:调用远程自定义操作.DLL:C:\Users\CUONG~1.HUY\AppData\Local\Temp\MSIF947.tmp,入口点:_RemoveExistingReristryKey@4MSI (c) (90:8C) [17:12:59:616]:隐形启用.MSI (c) (90:8C) [17:12:59:616]:在调用 Install on Server 之前尝试启用所有禁用的权限MSI (c) (90:8C) [17:12:59:616]:连接到 CA 接口的服务.RemoveExistingReristryKey:已删除先前安装的注册表项.操作结束 17:12:59:RemoveExistingReristryKey.返回值 1.

MSI (c) (90:54) [17:12:59:668]:执行操作:MaintenanceWelcomeDlg...

然而,我想修复的错误仍然发生,但是,如果我手动删除此注册表项,错误就会消失.

我想也许我的自定义操作执行得太晚了,所以我尝试通过自定义操作的一些选项进行编辑,例如:之前,之后,在 InstallExecuteSequence 中的序列以立即执行此自定义操作并在所有其他操作之前执行,但它仍然不是,它总是在标准动作CostFinalize"之后执行.

如何在运行 .msi 文件以删除注册表项时立即执行我的自定义操作?

非常感谢!

解决方案

我对您要尝试做什么感到困惑,但是,对我而言,这听起来您本质上是在尝试管理自定义操作发生——你有两个,而且它们以错误的顺序发生.

我有两条建议:如果您真的希望一个自定义操作在另一个之前发生,请在 InstallUISequence 中安排第一个,在 InstallExecuteSequence 中安排第二个.InstallUISequence 发生在 InstallExecuteSequence 之前.

第二个是使用

在这个例子中,我有两个自定义操作(圈出),我必须一个接一个.为了做到这一点,我做了一些类似的事情:

<自定义操作="SetCustomAction_EncryptKey"After="InstallInitialize"/><自定义操作="CustomAction_EncryptKey"After="SetCustomAction_EncryptKey"/></InstallExecuteSequence>

这保证了一个接一个发生.话虽如此,我也可以这样做,以确保第二个操作不一定发生在下一个操作,而是第一个操作之后的一个操作:

<自定义操作="SetCustomAction_EncryptKey"Before="CostFinalize"/></InstallUISequence><安装执行序列><自定义操作="CustomAction_EncryptKey"Before="CostFinalize"/></InstallExecuteSequence>

无论如何,我发现 ORCA 是一个工具,它揭开了整个何时安排自定义操作"的神秘面纱.

I'm trying to execute my custom action in wix installer to remove a registry key which was written before in the InstallExecuteSequence before installing a software as follows:

 <InstallExecuteSequence>
      <Custom Action="RemoveExistingReristryKey" Sequence="150">NOT Installed</Custom>
 </InstallExecuteSequence>

When running .msi file, the function RemoveExistingReristryKey was invoked and registry key was deleted and I can see the log:

... Action ended 17:12:59: CostFinalize. Return value 1.

MSI (c) (90:54) [17:12:59:596]: Doing action: RemoveExistingReristryKey Action 17:12:59: RemoveExistingReristryKey. Action start 17:12:59: RemoveExistingReristryKey. MSI (c) (90:E4) [17:12:59:616]: Invoking remote custom action. DLL: C:\Users\CUONG~1.HUY\AppData\Local\Temp\MSIF947.tmp, Entrypoint: _RemoveExistingReristryKey@4 MSI (c) (90:8C) [17:12:59:616]: Cloaking enabled. MSI (c) (90:8C) [17:12:59:616]: Attempting to enable all disabled privileges before calling Install on Server MSI (c) (90:8C) [17:12:59:616]: Connected to service for CA interface. RemoveExistingReristryKey: Deleted registry key of the previous installation. Action ended 17:12:59: RemoveExistingReristryKey. Return value 1.

MSI (c) (90:54) [17:12:59:668]: Doing action: MaintenanceWelcomeDlg ...

However, the error which I want to fix still happens, however, if I remove this registry key manually, the error disappear.

I think maybe my custom action executes too late, so I try to edit by some options of custom action such as: before, after, sequence in the InstallExecuteSequence to execute this custom action immediately and before all of other actions but it's still not, it always executes after standard action "CostFinalize".

How can I execute my custom action immediately when running .msi file to remove registry key?

Thank you so much!

解决方案

I'm confused as to what you're trying to do, but, to me, it sounds like you're essentially trying to manage when your custom actions happen -- you have two of them and they are happening in the wrong order.

I have two pieces of advice: if you really want one custom action to happen before the other, schedule the first one in the InstallUISequence and the second in the InstallExecuteSequence. The InstallUISequence happens before the InstallExecuteSequence.

The second is to really look at when your custom actions are happening using ORCA. Open your .msi file using ORCA, then go to the InstallExecuteSequence table, then click on the Sequence column to sort by "when the action happens".

Here's an example from an MSI that I have:

In this example I have two custom actions (circled) that I must have one-after-the-other. In order to do that, I did something along these lines:

<InstallExecuteSequence>
     <Custom Action="SetCustomAction_EncryptKey"
             After="InstallInitialize"/>
     <Custom Action="CustomAction_EncryptKey"
             After="SetCustomAction_EncryptKey"/>
</InstallExecuteSequence>

This guarantees that one happens right after the other. With that said, I could've done this, too, to make sure that the second one happened not necessarily the next action, but one of the actions after the first:

<InstallUISequence>
     <Custom Action="SetCustomAction_EncryptKey"
             Before="CostFinalize"/>
</InstallUISequence>
<InstallExecuteSequence>
     <Custom Action="CustomAction_EncryptKey"
             Before="CostFinalize"/>
</InstallExecuteSequence>

In any case, I've found ORCA to be a tool that demystified the entire "when to schedule custom actions".

这篇关于如何在所有其他操作之前执行自定义操作(包括标准和自定义操作)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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