GenerateTransform method with windows installer

Welcome Forums General PowerShell Q&A GenerateTransform method with windows installer

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years, 2 months ago.

  • Author
  • #5309

    Points: 0
    Rank: Member

    by mac-duff at 2012-11-28 07:06:04

    Hi there,

    I am facing problems by executing one function of the windows installer

    function Invoke-Method ($Object, $MethodName, $ArgumentList) {
    return $Object.GetType().InvokeMember($MethodName, 'Public, Instance, InvokeMethod', $null, $Object, $ArgumentList)
    $installer = New-Object -ComObject WindowsInstaller.Installer
    $database1 = Invoke-Method $installer OpenDatabase @($MSI_Path, $msiOpenDatabaseModeReadOnly)
    $database3 = Invoke-Method $installer OpenDatabase @($MSI_file3, $msiOpenDatabaseModeReadOnly)

    Invoke-Method $database3 GenerateTransform @($database1, $MST_Path)

    The problem is the GenerateTransform statement where all the time I get this error:

    Exception calling "InvokeMember" with "5" argument(s): "GenerateTransform,ReferenceDatabase,TransformFile"
    At C:\Users\shadmin\Desktop\mod.ps1:4 char:39
    + return $Object.GetType().InvokeMember < <<< ($MethodName, 'Public, Instance, InvokeMethod', $null, $Object, $ArgumentList)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodTargetInvocation

    and I really dont know where is the error because I call it exactly like MS does in the VBS which also works:

    Dim different:different = Database2.GenerateTransform(Database1, transform) : CheckError

    any ideas, thanks

    by DonJ at 2012-11-28 08:39:11

    Have you tried not using Invoke-Method?



    The issue is in the syntax of Invoke-Method, but that cmdlet is completely unnecessary, here. You should be able to use a much more VBS-like syntax.

    by mac-duff at 2012-11-28 22:58:22

    than I get the message that the method does not exist, but either I cant do it like this with opendatabase, so I think it is a normal behavior.
    I am also pretty sure that this method exist because it is part of the WindowsInstaller object

    When I execute it like this:

    Invoke-Method $database3 GenerateTransform $database1 $transform

    I dont get the above error but neither a transform file....

    by DonJ at 2012-11-29 07:10:18

    It might just not like being called through PowerShell > Framework > Interop > COM. Sorry – this isn't one I have much experience with, so basically guessing :(.

    by mac-duff at 2012-12-20 02:10:31

    well the problem was how I opened the DB also when I still dont understand the difference

    $database = $Installer.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $Null, $Installer, @($MSI_file2, 0))

The topic ‘GenerateTransform method with windows installer’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort