簡體   English   中英

PowerShell:在不安裝的情況下從 MSI 文件中獲取 MSI 產品代碼?

[英]PowerShell: Get the MSI product code out of a MSI file without installing?

是否有可能在不使用 PowerShell 安裝的情況下從 MSI 文件中檢索 MSI 產品代碼? 我想將 MSI 文件的產品代碼與機器上安裝的 MSI 代碼進行比較,以了解該文件是否是過去安裝的。

這是一個基於[本文][1]讀取產品代碼的腳本:

$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現在包含產品代碼。 [1]: http ://www.scconfigmgr.com/2014/08/22/how-to-get-msi-file-information-with-powershell/

從 MSI 包中獲取 ProductCode 的更短方法:

Get-AppLockerFileInformation -Path "C:\PathTo\my.msi" | select -ExpandProperty Publisher | Select BinaryName

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM