In article < >, Francis Libble
says...
> Can someone tell me how to get a list of running applications on
> Win32?
> I am essentially looking to get the same list as appears in the
> Applications tab of the Windows Task Manager.
Yes, I wonder where you'd get that information...
It isn't available in any of the Win32_Process class properties anyway, I looked
through them.
There are some that sound good:
---8<---
#!/usr/bin/perl -w
use strict;
use warnings;
use Win32::OLE qw(in);
my $wmi;
eval {
$wmi = Win32::OLE->GetObject("winmgmts:");
};
unless ($@) {
my $proc_set;
eval {
$proc_set = $wmi->InstancesOf('Win32_Process');
};
die ("InstancesOf failed: ", Win32::OLE->LastError, "\n") if ($@);
printf "%-6s%-20s%-20s%-20s\n", 'PID', 'Name', 'Caption', 'Description';
printf "%-6s%-20s%-20s%-20s\n", '-' x 5, '-' x 19, '-' x 19, '-' x 19;
foreach my $proc (in($proc_set)) {
printf "%-6s%-20s%-20s%-20s\n", $proc->{'ProcessID'}, $proc->{'Name'},
$proc->{'Caption'}, $proc->{'Description'};
}
} else {
die "Win32::OLE->GetObject failed: ", Win32::OLE->LastError, "\n";
}
---8<---
But no...
There is a utility in the Win2K Resource Kit called tlist.exe, which will print
running processes by pid, name AND if available, the very string that you are
looking for.
You could use the output of that program to capture your data.
It won't show threads of applications though, like iexplore.exe for example.
If you start several iexplore.exe, they will all show.
If you start one iexplore.exe, and press ctrl-n or right_click->"Open link in
new window", the following windows will not show up, making the list shorter
than in Task Manager.
That's expected, tlist.exe lists processes by pid, not by thread.
What do you need this for?
Are you planning to do something with SendKeys?
Hope this helps!
Petri