List Running Applications on Win32 (!Processes)

F

Francis Libble

Dear All

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. I can easily get the
equivalent of the Processes tab in Windows Task Manager (using
Win32::Setupsup or Win32::IProc) but I can't seem to find a way to
retrieve only the running applications.

Enumerating Window titles doesn't give me what I am looking for either
(hidden windows with titles show up)

Thanks

Flibble
 
S

Sisyphus

Francis said:
Dear All

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. I can easily get the
equivalent of the Processes tab in Windows Task Manager (using
Win32::Setupsup or Win32::IProc) but I can't seem to find a way to
retrieve only the running applications.

Enumerating Window titles doesn't give me what I am looking for either
(hidden windows with titles show up)

Win32::perfLib (part of libwin) or Win32::process::Info (my preference).

Cheers,
Rob
 
S

Sisyphus

Sisyphus said:
Win32::perfLib (part of libwin) or Win32::process::Info (my preference).

Oops - now that I read your post properly I'm not sure that either of
those modules supply what you want. Check them out, anyway :)

Cheers,
Rob
 
P

Petri

Francis Libble said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top