Wix 在安装过程中使用命令行卸载产品 [英] Wix uninstall product using command line during installation

查看:28
本文介绍了Wix 在安装过程中使用命令行卸载产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个 Wix 项目,试图安装一个简单的 .txt 示例文件.但是,作为先决条件,我想卸载以前的应用程序.

I made a Wix project that attemps to install a simple .txt example file. But, as a prerequisite, I want to uninstall a previous application.

为此,我知道 msiexec 允许您通过简单地编写以下代码来卸载产品:

To do so, I know msiexec allows you to uninstall a product by simply writing:

msiexec /x {PRODUCT_CODE}

在命令行上.

幸运的是,我知道这个 PRODUCT_CODE,所以我尝试创建一个 CustomAction 来在安装开始之前卸载该产品,如下所示:

Fortunately, I know this PRODUCT_CODE, so I tried to create a CustomAction to uninstall that product before the installation starts, like this:

<CustomAction Id="PropertyAssign" Property="SilentLaunch" Value="msiexec.exe /x {EA29682C-7DA1-441C-BF3E-702491F59258}" Execute="immediate" />
<CustomAction Id="SilentLaunch" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check" Impersonate="no" />

<InstallUISequence>
  <Custom Action="PropertyAssign" After="CostFinalize" />
  <Custom Action="SilentLaunch" After="PropertyAssign" />
</InstallUISequence>

但是当我运行 .msi 时,它说代码 2762 出现意外错误并退出安装.

But when I run the .msi, it says there was an unexpected error with code 2762 and exits installation.

我知道错误就在那一行,就像我抹掉它一样,一切正常.

I know the mistake is in that line, as if I erase it, everything goes ok.

知道如何在没有任何错误的情况下运行该命令行吗?

Any idea on how to run that command line without any mistakes?

推荐答案

UI 序列不应更改机器的状态.它应该只收集、验证并向用户报告数据.所有更改都必须在执行序列中进行.

The UI sequence should never make changes to the state of the machine. It should only gather, validate and report data to the user. All changes must be made in the execute sequence.

Windows/MSI ( _MSIExecute ) 中有一个互斥锁,它强制每台机器执行一个执行序列.因此,您不能从 MSI 调用 msiexec.但是您可以做的是编写一个主要升级规则来检测其他产品并将其删除.Windows Installer 标准操作 RemoveExisitingProducts 可以卸载任何 MSI,而不仅仅是您以前的版本.

There is a mutex in Windows / MSI ( _MSIExecute ) that enforces one execute sequence per machine. Therefore you cannot call msiexec from an MSI. But what you can do is author a Major Upgrade rule to detect the other product and remove it. The Windows Installer standard action RemoveExisitingProducts can uninstall any MSI not just previous versions of yourself.

这篇关于Wix 在安装过程中使用命令行卸载产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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