首先:应用程序新版本的产品 GUID 发生变化是正常现象,尽管也可以在不更改产品 GUID 的情况下升级某些应用程序(称为小升级 https://msdn.microsoft.com/en-us/library/windows/desktop/aa370037(v=vs.85).aspx- 相对于主要升级 https://msdn.microsoft.com/en-us/library/windows/desktop/aa369786%28v=vs.85%29.aspx更改产品 GUID)。同一产品的不同版本之间往往保持稳定的是升级代码(它定义了一系列相关产品)。 ProductCode 唯一标识产品(在特定版本中)。
这里列出了一些卸载选项:从命令行卸载 MSI 文件而不使用 msiexec https://stackoverflow.com/questions/450027/uninstalling-an-msi-file-from-the-command-line-without-using-msiexec/1055933#1055933.
我想您可以使用 MSI 文件名,如下所示section 3
,或者如果产品名称保持稳定,您可以将其与自动化一起使用来查找正确的产品 GUID 以卸载有问题的产品。我稍后会对此进行测试并更新答案。
UPDATE:一个通过“产品名称”卸载产品的示例 VBScript(假设它在各个版本中保持不变,通常会这样做,但不能保证 - 这取决于产品)。
在“添加/删除程序”中找到产品名称 - 或使用本答案底部链接的小 VBScript 导出一个小文本文件,其中包含所有已安装软件包的信息。
' On Error Resume Next ' Used to suppress errors
Const msiUILevelNone = 2
Const msiUILevelFull = 5
Const msiInstallStateAbsent = 2
Set installer = CreateObject("WindowsInstaller.Installer")
Set products = installer.ProductsEx("", "", 7)
installer.UILevel = msiUILevelFull ' Running with full GUI (if available in MSI)
' installer.UILevel = msiUILevelNone ' Will run uninstall silently, run script with admin rights
' Get the product name from the user
productname = InputBox("Please enter the product name for the MSI package you wish to uninstall:")
If productname = vbCancel Or Trim(productname) = "" Then
WScript.Quit(0)
End If
' Iterate over all MSI packages on the box
For Each product In products
currentproduct = product.InstallProperty("ProductName")
If LCase(currentproduct) = LCase(productname) Then
installer.ConfigureProduct product.productcode, 0, 2 ' msiInstallStateAbsent
MsgBox "Ran uninstall for: " & currentproduct
Exit For ' End product iteration, assuming only one product needed uninstall
End If
Next
Set installer = Nothing
MsgBox "Finished."
UPDATE:您可以使用 VBScript 为自己创建产品代码和产品名称的快速列表,如本答案底部所述:如何找到已安装的 MSI 设置的产品 GUID? https://stackoverflow.com/questions/29937568/how-can-i-find-the-product-guid-of-an-installed-msi-setup/29937569#29937569。我认为这个特定的 VBScript 非常简单。