BernieC has asked for the wisdom of the Perl Monks concerning the following question:
I've looked at Win32::OLE and I cannot figure out what the "GetObject" does. Its description isuse Win32::OLE qw(in); sub matching_processes { my($pattern) = @_; my $objWMI = Win32::OLE->GetObject('winmgmts://./root/cimv2'); my $procs = $objWMI->InstancesOf('Win32_Process'); my @hits; foreach my $p (in $procs) { push @hits => [ $p->Name, $p->ProcessID ] if $p->Name =~ /$pattern/; }
Win32::OLE->GetObject(MONIKER, DESTRUCTOR) The GetObject() class method returns an OLE reference to the specified object. The object is specified by a pathname optionally followed by additional item subcomponent separated by exclamation marks '!'. The optional DESTRUCTOR argument has the same semantics as the DESTRUCTOR in new() or GetActiveObject()Which I mostly can't understand. And worse, the man page for ::OLE doesn't seem to have a InstancesOf method {nor did I see anything in the man page about an "in" that could be exported}. I'm completely baffled. There must be a less obscure want to do this.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Find a windows process
by Discipulus (Canon) on May 16, 2022 at 16:50 UTC | |
by BernieC (Pilgrim) on May 16, 2022 at 21:39 UTC | |
by Anonymous Monk on May 17, 2022 at 08:34 UTC |