PowerShell:在不安装的情况下从 MSI 文件中获取 MSI 产品代码? [英] PowerShell: Get the MSI product code out of a MSI file without installing?
本文介绍了PowerShell:在不安装的情况下从 MSI 文件中获取 MSI 产品代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能在不使用 PowerShell 安装的情况下从 MSI 文件中检索 MSI 产品代码?我想将 MSI 文件的产品代码与安装在机器上的 MSI 代码进行比较,以确定该文件是否曾经安装过.
Is there a possibility to retreive the MSI product code out of a MSI file without installing it with PowerShell? I want to compare the product code of a MSI file with the MSI codes installed on a maschine to find out if the file was installed in the past.
推荐答案
这里有一个脚本,根据 这篇文章:
Here is a script that reads the product code based on this article:
$path = "pathto.msi"
$comObjWI = New-Object -ComObject WindowsInstaller.Installer
$MSIDatabase = $comObjWI .GetType().InvokeMember("OpenDatabase","InvokeMethod",$Null,$comObjWI,@($Path,0))
$Query = "SELECT Value FROM Property WHERE Property = 'ProductCode'"
$View = $MSIDatabase.GetType().InvokeMember("OpenView","InvokeMethod",$null,$MSIDatabase,($Query))
$View.GetType().InvokeMember("Execute", "InvokeMethod", $null, $View, $null)
$Record = $View.GetType().InvokeMember("Fetch","InvokeMethod",$null,$View,$null)
$Value = $Record.GetType().InvokeMember("StringData","GetProperty",$null,$Record,1)
$Value
现在包含产品代码.
这篇关于PowerShell:在不安装的情况下从 MSI 文件中获取 MSI 产品代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文