Hello,
I am trying to use the windows installer COM object with powershell
and I'm running into problems. It looks like the shell holds on to
the .wsi file that I'm trying to change with an UPDATE call, so I can
run the ps1 script exactly once and after that I cannot access the
file (either through the shell or a tool like ORCA) until I close the
shell.
I confirmed this fact using the windows process explorer. After
executing the ps1 script I can find the .wsi file under "find handle"
and it is held by the shell from which the script was executed.
So, I created a VB script that essentially does the exact same operation on
the .wsi file and it turns out that I can run this any number of times
from the same shell without any problems.
What am I missing????
I have included the VB and PS1 script here. Any help is appreciated.
=======================VB SCRIPT
Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer")
Dim databasePath:databasePath = Wscript.Arguments(0)
Dim database : Set database = installer.OpenDatabase(databasePath, 1)
Dim query, view
query = Wscript.Arguments(1)
Set view = database.OpenView(query)
view.Execute
database.Commit
>>>>cscript blah.vbs "blah.wsi", "UPDATE property SET property.value='3.0' WHERE property.property='productversion' "
=======================PS1 SCRIPT
$file = $args[0]
$installer = new-object -comobject "WindowsInstaller.Installer"
$database = $installer.InvokeMethod( "OpenDatabase", $file, 1 )
$view = $database.InvokeMethod( "OpenView", "UPDATE Property SET
Property.Value='32.0' WHERE Property.Property='ProductVersion' ")
$view.InvokeMethod( "Execute" )
$view.InvokeMethod( "Close" )
$database.InvokeMethod( "Commit" )
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($installer)
$installer = $null
>>>>> blah.ps1 "blah.wsi"
=========================Types.ps1xml, has to be called using update-
typedate Types.ps1xml before running the ps1 script
System.__ComObject
[script removed]
InvokeMethod
[script removed]
$type = $this.gettype();
#write-host $type
$index = $args.count -1 ;
#write-host "Index :" $index
$methodargs=$args[1..$index]
#write-host $methodargs
#write-host "Arg 0 :" $args[0]
$type.invokeMember($args[0],
[System.Reflection.BindingFlags]::InvokeMethod,$null,$this,
$methodargs)
[script removed]