MSI 安装失败,因为“已安装此产品的另一个版本”

发布于 2024-09-28 07:57:03 字数 594 浏览 3 评论 0原文

我们使用 MSIEXEC 和以下命令行选项安装应用程序 (MSI):

MsiExec.exe /x{code} /qn /liwearucmopvx+ C:\Log\UnInstall.tra
MsiExec.exe /iC:\Source\App.msi /qn TARGETDIR=C:\Install ALLUSERS=1 /liwearucmopvx+ %C:\Log\Install.tra

大多数情况下这有效,但有时卸载失败(还不知道为什么,请查看错误)。无论如何,当发生这种情况时,我在重新安装过程中会收到以下错误:

Another version of this product is already installed.  Installation of this version cannot continue.  To configure or remove the existing version of this product, use Add/Remove Programs on the Control Panel

有办法绕过此错误吗?意思是确保我们总是重新安装(如果它存在,我们可以简单地自动将其吹走?)

We install an application (MSI) using MSIEXEC with the following command line option:

MsiExec.exe /x{code} /qn /liwearucmopvx+ C:\Log\UnInstall.tra
MsiExec.exe /iC:\Source\App.msi /qn TARGETDIR=C:\Install ALLUSERS=1 /liwearucmopvx+ %C:\Log\Install.tra

Most of the time this works, but sometimes the uninstall fails (not sure why yet, looking into the error). Anyways when this happens I get the following error during the re-install:

Another version of this product is already installed.  Installation of this version cannot continue.  To configure or remove the existing version of this product, use Add/Remove Programs on the Control Panel

Is there a way to bypass this? Meaning to ensure that we always re-install (if it exists we can simply automatically blow it away?)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

永不分离 2024-10-05 07:57:03

查看有关升级表的 MSDN 文档< /a>,基本上您需要设置 msidbUpgradeAttributesVersionMaxInclusive 位。

如果您使用 WiX 3.5 或更高版本,则无需说明用于构建安装程序的内容您可以使用 MajorUpgrade/@AllowSameVersionUpgrades="yes" 来为您处理此问题。

请注意,因为 MSI 忽略了
第四个产品版本字段,设置
此属性设置为 yes 也允许
前三名时降级
产品版本字段相同。
例如,产品版本1.0.0.1
将“升级”1.0.0.2998 因为
它们被视为同一版本
(1.0.0)。这可能会重新引入
严重的错误,所以最安全的选择是
更改前三个版本
fields 并省略该属性即可得到
默认为否。

请注意,下面的 VBScript 将通过搜索已安装的列表按名称删除包,而不必记住包代码(如果您在持续集成中使用自动生成的包代码,这真的很痛苦)产品并查找包装代码本身。

Option Explicit
Dim productName, productCode, installer 
productName = "My Application"

Set installer = Wscript.CreateObject("WindowsInstaller.Installer")

For Each productCode In installer.Products
    If InStr(1, LCase(installer.ProductInfo(productCode, "ProductName")), LCase(productName)) Then Exit For
Next

If Not IsEmpty(productCode) Then    
    Dim WshShell, oExec
    Set WshShell = CreateObject("WScript.Shell")
    Set oExec = WshShell.Exec("msiexec /x " & productCode & " /qb /l*v ""%temp%\UninstallApp.log"" ")
End If

Check out the MSDN Documentation on the Upgrade Table, basically you need to set the msidbUpgradeAttributesVersionMaxInclusive bit.

You don't state what you're using to build your installer, if you're using WiX 3.5 or later you can use MajorUpgrade/@AllowSameVersionUpgrades="yes" to take care of this for you.

Note that because MSI ignores the
fourth product version field, setting
this attribute to yes also allows
downgrades when the first three
product version fields are identical.
For example, product version 1.0.0.1
will "upgrade" 1.0.0.2998 because
they're seen as the same version
(1.0.0). That could reintroduce
serious bugs so the safest choice is
to change the first three version
fields and omit this attribute to get
the default of no.

Note that instead of having to remember the package code (a real pain if you're using auto-generated package codes with Continuous Integration) the following VBScript will remove the package by name by searching the list of installed products and finding the package code itself.

Option Explicit
Dim productName, productCode, installer 
productName = "My Application"

Set installer = Wscript.CreateObject("WindowsInstaller.Installer")

For Each productCode In installer.Products
    If InStr(1, LCase(installer.ProductInfo(productCode, "ProductName")), LCase(productName)) Then Exit For
Next

If Not IsEmpty(productCode) Then    
    Dim WshShell, oExec
    Set WshShell = CreateObject("WScript.Shell")
    Set oExec = WshShell.Exec("msiexec /x " & productCode & " /qb /l*v ""%temp%\UninstallApp.log"" ")
End If
做个ˇ局外人 2024-10-05 07:57:03

这个问题很老了,但是现有的答案缺少问题和解决方案的本质,但对于其他场景很有用:

  1. 如果卸载失败,则说明问题很严重,并且没有更好的方法比分析这个更重要的方法 - 否则你以后可能会遇到更多麻烦

  2. 至少,我会编写一个小脚本/程序,它使用卸载的返回值,或者更强大的是,在尝试安装新的 MSI 之前测试 MSI 是否仍然安装。
    如果对此感兴趣,我会提供更多关于如何执行此操作的信息,但在其他问题中已经有关于 SO 的信息。

  3. 其他一些答案建议您应该使用主要升级(在这种情况下,每个新版本都可以/应该是正确的主要升级,至少作为建议)。这是一个很好的建议,但如果卸载“有时”失败,则没有帮助。
    此外,重要的是要声明,大多数情况下,您提到的错误表明您尚未使用主要升级。
    如果您确实存在卸载问题,那么主要升级可能会增加问题,因为根据配置,它可以第二次安装该产品 MSI,并且您对此有两个 MSI 参考,但仍然是一个产品你。更多的细节会导致太过分。请记住,在进一步的更新步骤之前,必须确保(始终)有效的卸载或至少对此进行测试。

  4. saschabeaumont 的脚本非常短小精悍。它所做的就是确保您确实使用了正确的产品代码。主要需求是,因为每次都必须更改,所以您需要进行重大升级......
    对于您的情况:这只能解决一种情况,即为什么您的卸载可能会失败...

The question is quite older, but the existing answers are missing the essence of problem and solution while useful for other scenarios:

  1. If the uninstall fails, you have a serious problem, and there is no better way than analyzing this- otherwise you could get in more trouble later.

  2. At least, I would write a small script/program, which uses the return value of the uninstall or, even more powerful, tests, if the MSI is still installed- BEFORE you try to install the new MSI.
    I would give more information how to do this, if there is interest in this, but there is already information on SO in other questions.

  3. Some other answers recommand, that you should use Major Upgrades (every new build can/should be a correct Major Upgrade in this scenario, at least as a recommendation). This is a good recommendation, but does not help, if uninstalls are failing "sometimes".
    Moreover it is important to state, that most often, the error you mention, shows that you are not using Major Upgrades already.
    If you have really a problem with uninstalls, then a Major Upgrade could increase problems, because dependent on the configuration, it can install the product a second-time MSI-wise and you have two MSI references on this, what is still one product for you. More details would lead too far. Just remember, an (always) working uninstall or at least a test for this has to be assured before further update steps.

  4. The script from saschabeaumont is really short and nice. What it is doing, is to assure, that you are really using the correct ProductCode. The main need is, because it has to change every time, you produce a Major Upgrade...
    In your case: This solves only ONE scenario, why your uninstall could have failed...

甜心小果奶 2024-10-05 07:57:03

如果卸载失败,产品仍将在系统上注册 - 根据失败发生的位置,卸载将回滚,使产品仍处于安装状态。

如果您尝试在现有安装之上重新安装具有相同产品代码但不同版本的产品,MSI 将正确地抱怨该产品仍然安装。如果要实现升级行为,则需要更改产品代码并将条目写入升级表,以便 MSI 可以区分新旧产品,并在新版本发布之前或之后使用“RemoveExistingProducts”操作删除旧产品放下。

如果您想了解卸载失败的原因,您需要查看日志,通常查找“返回值 3”,这是安装操作失败的签名。

If the uninstallation fails the product will still be registered on the system - depending on where the failure occurs the uninstallation will rollback, leaving the product still installed.

If you attempt to reinstall a product with the same product code but different version on top of an existing installation MSI will complain, rightly, that the product is still installed. If you want to achieve upgrade behaviour then you need to change the product code and write entries into the upgrade table so that MSI can discriminate between the old and new products and use the RemoveExistingProducts action to remove the old product before or after the newer version is laid down.

If you want to understand why the uninstallation failed, you need to look at the logs, typically look for 'return value 3' which is the signature of a failed installation action.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文