1
我必須從應用MST的MSI中讀取一些信息。我知道如何從純MSI讀取表格,但不知道如何應用MST。Powershell獲取MST信息
我用這個微星:
Process {
try {
# Read property from MSI database
$WindowsInstaller = New-Object -ComObject WindowsInstaller.Installer
$MSIDatabase = $WindowsInstaller.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $null, $WindowsInstaller, @($Path.FullName, 0))
$Query = "SELECT Value FROM Property WHERE Property = '$($Property)'"
# $Query = "SELECT Action FROM CustomAction WHERE Action = '$($CustomAction)'"
$View = $MSIDatabase.GetType().InvokeMember("OpenView", "InvokeMethod", $null, $MSIDatabase, ($Query))
$View.GetType().InvokeMember("Execute", "InvokeMethod", $null, $View, $null) | out-null
$Record = $View.GetType().InvokeMember("Fetch", "InvokeMethod", $null, $View, $null)
try {
$Value = $Record.GetType().InvokeMember("StringData", "GetProperty", $null, $Record, 1)
# Commit database and close view
$MSIDatabase.GetType().InvokeMember("Commit", "InvokeMethod", $null, $MSIDatabase, $null) | out-null
$View.GetType().InvokeMember("Close", "InvokeMethod", $null, $View, $null) | Out-Null
$MSIDatabase = $null
$View = $null
} catch {
$Value = "-"
}
# Return the value
return $Value
如果有人能幫助我,這將是非常好的!
謝謝,莫里茨:)