MSI安装失败,因为“此产品的另一个版本已安装" [英] MSI Install Fails because "Another version of this product is already installed"

查看:400
本文介绍了MSI安装失败,因为“此产品的另一个版本已安装"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?)

推荐答案

查看

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

如果您使用的是 WiX 3.5 或更高版本,您可以使用MajorUpgrade/@AllowSameVersionUpgrades="yes"帮您解决这个问题.

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.

请注意,由于MSI会忽略 第四个产品版本字段,设置 将此属性设置为是"还允许 下三级降级时 产品版本字段相同. 例如,产品版本1.0.0.1 将升级" 1.0.0.2998,因为 他们被视为相同的版本 (1.0.0).那可能会重新介绍 严重的错误,所以最安全的选择是 更改前三个版本 字段并忽略此属性以获取 默认为否.

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.

请注意,以下VBScript无需记住程序包代码(如果您在连续集成中使用自动生成的程序包代码,这真是痛苦),而是通过搜索 name 来删除程序包中的 name .已安装产品的列表,并查找包装代码本身.

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

这篇关于MSI安装失败,因为“此产品的另一个版本已安装"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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