Similar Threads:
1.Need an idiot check on technique for releasing out-of-process COM object in PowerShell
2.New-object preventing process from exiting
We have a C++ application that has an automation object model.
In PowerShell we create a new instance of the object model via New-Object.
Everything works as expected in terms of calls to the created object.
Problems arise if the user closes the application first, then closes
PowerShell. The process of the application will not have exited, as seen by
Task Manager.
If PowerShell is exited, and then the application the process will exit
correctly.
What type of solution can I provide to my customers where they don't have to
worry about the order in which the application and PowerShell are exited?
Thanks for any insight.
3.Powershell interacting with COM automation object with late binding
Hello All,
I have a quick question relating to powershell interacting with COM
automation object with late binding, is it possible?
For instance , while in a classical VB (with Excel) IDE I'm able to do
the following:-
Dim objStationApp As Object
Set objStationApp = CreateObject("Station.Application")
objStationApp.Connect "C:\Program Files\Honeywell\Experion
PKS\Client\Station\Default.stn"
objStationApp.CurrentPage = "C:\TEMP\Display1.htm"
objStationApp.Quit
Set objStationApp = Nothing
however using Powershell
$a=New-Object -COM Station.Application;
$a.Connect("C:\Program Files\Honeywell\Experion
PKS\Client\Station\Default.stn");
$a.CurrentPage = "C:\TEMP\Display1.htm"
$a.Quit
I get the following error :-
Method invocation failed because [System.__ComObject] doesn't contain a
method
named 'Connect'.
Does this mean that Powershell can't access Automation COM objects with
late bindings?
Thanks in advanced
Karl
4.Powershell V/s VB script windows installer COM object
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]
$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..$index]
#write-host $methodargs
#write-host "Arg 0 :" $args]
$type.invokeMember($args],
[System.Reflection.BindingFlags]::InvokeMethod,$null,$this,
$methodargs)
[script removed]
5.Howto: Use a com object in Powershell
I am trying to use a com object instance of the Novell volume administration
control (nwvola.ocx) to list file details on a Netware server. I have used
this technique successfully with vbscript and vb.net. Here's what I get:
PS C:\> $vol = New-Object -comObject "NWVolAdmLib.NWVolAdmCtrl.1"
PS C:\> $vol | Get-Member
TypeName: System.__ComObject#{ebe2fdab-6c8f-11d1-a149-00401c6047e4}
Name MemberType Definition
---- ---------- ----------
AboutBox Method void AboutBox ()
FindEntry Method INWEntry FindEntry (string)
Load Method bool Load ()
Unload Method bool Unload ()
PS C:\>
The problem is that only the methods are listed (there are several
properties), and I cannot read or set the properties. This also happens with
other Novell objects.
6. returning COM objects from PowerShell CmdLet
7. PowerShell cannot use (dynamic) COM objects
8. COM Object problem powershell / frames