本文介绍了获取在安装和卸载时运行的自定义操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了延迟自定义操作类型 18.我在互联网上阅读了很多资料,包括这个类似的问题如何添加仅在卸载时发生的 WiX 自定义操作(通过 MSI)?这给出了一个很大的属性真值表,但似乎没有任何东西与我的 Wix 体验相匹配.我已升级到最新的 Wix 3.11.

I've experimented with deferred custom action type 18. I've read a lot of material on the internet including this similar questionHow to add a WiX custom action that happens only on uninstall (via MSI)?which gives a big truth table of properties, but nothing seems to match my experiences with my Wix. I've upgraded to the latest Wix 3.11.

文件元素在目录结构内...

File element is within the directory structure...

<File Id='ReplaceRegistryEntriesFile' Source='MikeyRegistryReset.bat'
      DiskId='1'
/>

剩下的在产品下...

<InstallExecuteSequence>
<Custom Action="RunOnUninstall"
        After="InstallInitialize"
>
</Custom>
</InstallExecuteSequence>

<CustomAction Id="RunOnUninstall"
    FileKey="ReplaceRegistryEntriesFile"
    ExeCommand=" mabwashere"
    Impersonate="no" Return="asyncNoWait"
    Execute="deferred"
/>

它实际上导致脚本在卸载阶段运行.为什么它在安装阶段没有运行?目前没有任何逻辑(可能已经在上面的链接中解释过)阻止它在它想要运行的任何时候运行.我希望它在安装和卸载过程中都能运行.

It's actually causing the script to run during the uninstall phase.Why didn't it run during the installation phase? There is no logic (that could possibly have been placed there explained in the link above) currently there to stop it from running anytime it wants to run. I was expecting it to run during both install and uninstall.

越来越奇怪了.如果我将 After="InstallInitialize" 更改为 Before="InstallFinalize",则我的批处理文件仅在安装期间运行.

It gets more strange. If I change After="InstallInitialize" to Before="InstallFinalize", my batch file then only runs during installation.

也许这是延迟自定义操作所独有的!那么延迟的自定义操作是否只在安装/卸载周期中运行一次?我没有看到任何文档告诉我这一点.

Maybe this is unique to deferred custom actions! So is a deferred custom action only ever run once in the Install/Uninstall cycle? I've seen no documentation to tell me this.

WTF 正在进行中?

推荐答案

好吧,我有一个可以运行的版本.我有两个延迟的自定义操作,一个运行 Before="RemoveRegistryValues",另一个是 After="InstallFiles".它们都调用相同的 .bat 文件,但在安装和卸载过程中传递了不同的参数(在我的例子中是 INSTALL 和 UNINSTALL 值).

Well I've got a version working. I've got two deferred custom actions, one runs Before="RemoveRegistryValues", the other one is After="InstallFiles". They both call the same .bat file, but pass a different argument during install and uninstall (the values INSTALL and UNINSTALL in my case).

一些代码...

<InstallExecuteSequence>
<Custom Action="RunOnUninstall"
        Before="RemoveRegistryValues"
>
</Custom>
<Custom Action="RunOnInstall"
        After="InstallFiles"
>
</Custom>
</InstallExecuteSequence>

<CustomAction Id="RunOnUninstall"
    FileKey="ReplaceRegistryEntriesFile"
    ExeCommand=" UNINSTALL"
    Impersonate="no" Return="asyncNoWait"
    Execute="deferred"
/>
<CustomAction Id="RunOnInstall"
    FileKey="ReplaceRegistryEntriesFile"
    ExeCommand=" INSTALL"
    Impersonate="no" Return="asyncNoWait"
    Execute="deferred"
/>

虽然我在测试过程中发现了一些问题:

There are a couple of problems though I discovered during testing:

问题 1:File 元素在目录结构中.我被迫使用 file 元素来运行自定义操作类型为 18 的批处理文件(带有 .bat 扩展名),并且该文件元素必须放置在目录结构中,以便将文件安装到计算机上.我做了一些测试,并且可以在安装 .msi 后修改该文件/批处理脚本(尽管具有管理员权限),导致卸载可能无法正常工作.我认为延迟的自定义操作将文件保存在 .msi 脚本中并运行它.但这并没有发生,它正在运行卸载过程中当前文件结构中的批处理脚本.如果有人有关于如何纠正这种行为的提示,我仍然愿意倾听.

Problem 1: The File element is in the directory structure. I was forced to use the file element to run a batch file (with .bat extension) with custom action type 18, and that file element had to be placed in the directory structure causing the file to be installed on the computer. I did some testing, and that file/batch script can be modified after the .msi is installed (with admin privilege albeit), causing the uninstall to possibly not work correctly. I thought that deferred custom actions keep the file in the .msi script and run that. But this is not happening, it's running the batch script that is currently in the file structure during uninstall. If anyone has tips on how to correct this behaviour I'm still willing to hear about it.

问题 2. 当我安装 .msi 时,在批处理脚本中执行的注册表更改会立即生效(在这种情况下,NeverShowExt 已被删除),并且丢失的文件扩展名会立即显示.但是当卸载 .msi 并替换注册表项时,文件扩展名仍会显示,直到我注销并重新登录.

Problem 2. When I install the .msi, the registry changes that were performed in the batch script take effect immediately (in this case NeverShowExt was removed), and the missing file extensions show immediately. But when the .msi is uninstalled and the registry entries are replaced, the file extensions still show until I log out and log back in.

问题 3:还是和以前一样的问题,这都是无证行为.任何可以向我指出一些解释为什么这是有效的文档的人都将不胜感激.

Problem 3: Still the same problem as before, this is all undocumented behaviour. Anyone that can point me to some documentation that explains why this is working would be appreciated.

即使存在上述问题,我实际上还是很高兴我的产品可以正常工作.因此,我将继续使用它并继续做其他事情,直到有人向我提供更多信息来解决我上面列出的问题.

Even with the above problems, I'm actually quite happy I've got my product working. So I'm going to run with it and go on with other things now, until perhaps someone gives me more information addressing the problems I listed above.

这篇关于获取在安装和卸载时运行的自定义操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 14:37