使用msiexec卸载应用程序时,GUID可以替代吗? [英] Is there an alternative to GUID when using msiexec to uninstall an application?

查看:180
本文介绍了使用msiexec卸载应用程序时,GUID可以替代吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行包含msiexec的卸载脚本时,我们当前正在使用GUID来识别应用程序.我遇到的问题是,每次安装最新版本的应用程序时,GUID都会更改,因此我想知道是否可以通过其他方式识别使用msiexec运行的应用程序?

We're currently using a GUID to identify the application when running our uninstall script which contains msiexec. The problem I'm having is the GUID changes every time I install the latest version of the application, so I was wondering if there is a different way that I can identify our application running using msiexec?

推荐答案

首先:产品GUID对于应用程序的新版本更改是正常的,尽管也可以升级某些应用程序而无需更改产品GUID(称为

First of all: it is normal that the product GUID changes for new versions of the application, though it is also possible to upgrade some applications without changing the product GUID (referred to as minor upgrades - as opposed to major upgrades that change the product GUID). What tends to remain stable between different releases of the same product is the UpgradeCode (it defines a family of related products). ProductCode uniquely identifies a product (in a specific version).

此处列出了一些卸载选项:

There are some options for uninstall listed here: Uninstalling an MSI file from the command line without using msiexec.

我想您可以使用section 3中所示的MSI文件名,或者如果产品名称保持稳定,则可以将其与自动化一起使用,以查找正确的产品GUID来卸载有问题的产品.我将稍后进行测试并更新答案.

I suppose you could use the MSI file name as illustrated in section 3, or if the product name remains stable you could use it along with automation to look up the correct product GUID to uninstall the product in question. I will test this in a moment and update the answer.

更新:一个用于按产品名称"卸载产品的示例VBScript(假设它在各个发行版中保持不变,通常这样做,但不能保证-它取决于产品).

UPDATE: A sample VBScript to uninstall product by "product name" (assuming it remains constant across releases, which it normally does, but there is no guarantee - it depends on the product).

在添加/删除程序"中找到产品名称-或使用此答案底部链接到的小VBScript导出带有所有已安装软件包信息的小文本文件.

Find the product name in Add/Remove Programs - or use the tiny VBScript linked to at the bottom of this answer to export a little text file with info for all installed packages.

' 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."


更新:您可以使用VBScript创建自己的产品代码和产品名称的快速列表,如该答案底部所述:


UPDATE: You can create yourself a quick list of product codes and product names using VBScript as described towards the bottom of this answer: How can I find the product GUID of an installed MSI setup? . This particular VBScript is as simple as it can possibly get I think.

这篇关于使用msiexec卸载应用程序时,GUID可以替代吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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