1

Good afternoon I need to change the values in the table MSI Usual choice of tables to make out, but here's the problem with the change.

for example select:

$WindowsInstaller = New-Object -com WindowsInstaller.Installer
$Database = $WindowsInstaller.GetType().InvokeMember(“OpenDatabase”, “InvokeMethod”, $Null, $WindowsInstaller, ($msi_path,0))
$View = $Database.GetType().InvokeMember(“OpenView”, “InvokeMethod”, $Null, $Database, (“SELECT * FROM Control WHERE Control = 'LicenseText'”)) ....

($msi_path,0), 0 open table from read, if i try not 0 (1 or 2), I get an error:

[MethodInvocationException: Exception calling "InvokeMember" with "5" argument(s): "OpenDatabase,DatabasePath,OpenMode"]

Someone tell me what could be the problem. Or maybe there's another way to change the values in the table are interested in powershell.

1 Answers1

2

I was going to solve.

Is work, update value from table Msi runs correctly

Function Change-MSIProperties($msi_path) {
    $Database = $null
    $View = $null
    [int]$msiOpenDatabaseMode = 2
    $WindowsInstaller = New-Object -com WindowsInstaller.Installer
    $Database = $WindowsInstaller.GetType().InvokeMember('OpenDatabase', 'InvokeMethod', $Null, $WindowsInstaller, ($msi_path,$msiOpenDatabaseMode))
    $View = $Database.GetType().InvokeMember('OpenView', 'InvokeMethod', $Null, $Database, ('UPDATE Feature SET Feature.Level=1 WHERE Feature.Level=0'))
    $View.GetType().InvokeMember('Execute', 'InvokeMethod', $Null, $View, $Null)| Out-Null

    $View.GetType().InvokeMember('Close', 'InvokeMethod',$Null,$View,$Null) | Out-Null
}
beatcracker
  • 6,714
  • 1
  • 18
  • 41