以编程方式检测正在安装的 MSI 包 [英] Programmatically detect MSI package being installed

查看:33
本文介绍了以编程方式检测正在安装的 MSI 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否正在安装/升级软件包.

I would like to know if a package is being installed/upgraded.

MSI 引擎设置了全局互斥锁,但与产品无关.

MSI engine sets a global mutex but doesn't relate to the product.

我的一个想法是扫描正在运行的 msiexec 实例并检查命令行参数以确定 msi 文件并扫描其产品代码,但我想看看是否有更好的选择,尽管找不到任何合适的API.

One idea I have is to scan running msiexec instances and check the command line parameters to determine the msi file and scan for its product code, but I would like to see if there is a better option although couldn't find any suitable API.

谢谢

推荐答案

Major Upgrade:如果您的 MSI 正在执行重大升级,那么之前的产品代码版本将添加到 ActionProperty 的属性中="nofollow noreferrer">最新包的升级表.在 WiX 中,这个属性通常被称为 WIX_UPGRADE_DETECTED,但它可以被称为任何东西.

Major Upgrade: If your MSI is performing a major upgrade, then the product code of the previous version will be added to the property specified as the ActionProperty in the Upgrade table of the newest package. In WiX this property is generally called WIX_UPGRADE_DETECTED by convention, but it can be called anything.

换句话说,检查 WIX_UPGRADE_DETECTED 或等效属性是否具有任何值可用于检测是否正在进行升级.

In other words, checking whether WIX_UPGRADE_DETECTED or an equivalent property has any value at all can be used to detect that an upgrade is taking place.

UPGRADINGPRODUCTCODE:在较旧的设置中 - 在主要升级期间被卸载的设置 - 内置 MSI 属性(与您声明的相反)UPGRADINGPRODUCTCODE 将设置为较新设置的产品代码.换句话说,您可以在旧包的条件下使用此属性 (UPGRADINGPRODUCTCODE),但不会在较新的设置中设置.这是一个非常常见的混淆.

UPGRADINGPRODUCTCODE: In the older setup - the one that is being uninstalled during the major upgrade - the built-in MSI property (as opposed to one you declare) UPGRADINGPRODUCTCODE will be set to the product code of the newer setup. In other words you can use this property (UPGRADINGPRODUCTCODE) in conditions in the old package, but it will not be set in the newer setup. This is a very common confusion.

查找已安装产品:您可以轻松获取已安装产品的产品代码:如何找到已安装的 MSI 设置的产品 G​​UID? MSI API 具有许多可用于确定的方法和属性关于已安装的 MSI,几乎可以满足您的任何需求.可以通过COM、Win32、托管代码访问.

Finding Installed Product: You can get the product code for an installed product easily: How can I find the product GUID of an installed MSI setup? The MSI API features a lot of methods and properties that can be used to determine pretty much whatever you want about an installed MSI. It can be accessed via COM, Win32, Managed code.

更新:此处的脚本显示了如何通过 MSI API 相关产品调用识别相关产品.向底部.

<小时>

一些链接:

  • Run Wix Custom action only during uninstall and not during Major upgrade (more elaborate description of the properties mentioned above - different words and formatting)
  • MSI Tip: Informing the User When a Major Upgrade Will Take Place (Flexera)
  • wix installer update process and confirmation dialog (An implementation in VBScript - of all things - showing a dialog to the user on major upgrade. I would not recommend this, but it is just a sample).
  • check for windows installer mutex availability

这篇关于以编程方式检测正在安装的 MSI 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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