简体   繁体   English

Windows安装程序,检查软件包是否存在

[英]Windows installer, check existence of package

Using windows, I can uninstall software via script/command line as follows: 使用Windows,我可以通过脚本/命令行卸载软件,如下所示:

msiexec /x {00000000-0000-0000-0000-000000000000}

Is there a method to just test for the existence of the given package, without affecting it? 有没有一种方法可以在不影响给定软件包的情况下对其进行测试?

I'm interested in a true/false or any other input, indicating whether the package exists on the machine, and can be removed using Windows installer with the given command. 我对true / false或任何其他输入感兴趣,这些输入指示软件包是否在计算机上存在,并且可以使用Windows安装程序通过给定命令将其删除。

For context: I'm using NSIS, and need to modify my installer behavior in case a specific package is found. 对于上下文:我正在使用NSIS,并且需要修改安装程序的行为,以防发现特定的软件包。 Command-line can be used as it can return values, and VBScript can be used via cmd as well. 可以使用命令行,因为它可以返回值,也可以通过cmd使用VBScript。

Absolutely no affect on the package is mandatory, and also no indication of the process to the user, so repair isn't acceptable for example. 绝对不会对包装产生任何影响,也不会向用户显示这一过程,因此,例如,维修是不可接受的。

The "proper" way to find this out is to call a function such as MsiQueryProductState . 找出问题的“正确”方法是调用MsiQueryProductState的函数。 This is available in various other fashions including the VB-accessible Installer.ProductState property . 这可以通过其他各种方式使用,包括VB可访问的Installer.ProductState属性 If instead you're trying to generate a list of what is on the machine, MsiEnumProducts or Installer.Products (or their Ex variants) are more appropriate. 相反,如果您尝试生成计算机上的内容的列表,则MsiEnumProductsInstaller.Products (或其Ex变体)更合适。 It appears that PowerShell can access equivalent information through WMI calls. 看来PowerShell可以通过WMI调用访问等效信息。

Less proper approaches would include calling msiexec /f {PROD-UCT-CODE} to either repair the product or fail to find it, or querying the registry directly for the presence of the product's Uninstall key entry, (it's subkey name matches the {PROD-UCT-CODE} ; check both 32-bit and 64-bit keys as well as both per-machine and per-user installations as required) for example with reg query . 不太合适的方法包括调用msiexec /f {PROD-UCT-CODE}来修复产品或找不到产品,或者直接在注册表中查询产品的Uninstall密钥项的存在,(其子项名称与{PROD-UCT-CODE}匹配{PROD-UCT-CODE} ;同时检查32位和64位密钥,以及根据需要检查每台计算机和每位用户的安装),例如使用reg query

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM