VBS works, PS no - WindowsInstaller.Installer

by mac-duff at 2012-12-20 02:16:08

Hi,
well, I want to check if a table exist in a MSI file but its failing in the PS version and I have no idea because its the same…


Dim oInstaller : Set oInstaller = CreateObject(“WindowsInstaller.Installer”)

Dim oDatabase : Set oDatabase = oInstaller.OpenDatabase(“C:\Users\shadmin\Desktop\7z920-x64.msi”,0)

If oDatabase.TablePersistent(“Registry”) = 1 Then
msgbox "exist"
end if



$installer = New-Object -Com ‘WindowsInstaller.Installer’
$MSI_file2 = “C:\Users\shadmin\Desktop\7z920-x64.msi”
$database = $Installer.GetType().InvokeMember(“OpenDatabase”, “InvokeMethod”, $Null, $Installer, @($MSI_file2, 0))

if (($database.GetType().InvokeMember(“TablePersistent”, “InvokeMethod”, $Null, $database, “Registry”)) -eq 1) {
write-host ‘exist’
}


Any idea what could be the prob? Finally the source is the same…
by DonJ at 2012-12-20 06:40:02
It’s possible that the COM object just isn’t making it through Interop correctly. PowerShell (technically, .NET) isn’t 100% compatible with COM.
by mac-duff at 2012-12-21 00:56:39
got it working


$database.GetType().InvokeMember(“TablePersistent”, “GetProperty”, $Null, $database, “Registry”)