DBD-WMI reviews

RSS | Module Info | Add a review of DBD-WMI

DBD-WMI (0.06) ****

I've searched for a perl module to list all processes running on a Windows machine and receive PID, PPID and the command line. With this WMI module it is very simple and fast.

But I also had a problem to get command lines of processes of other logins. With the code AllowPriv() call this works with this WMI module.

Very smart module!!

use strict;
use DBI;

use Win32API::Registry qw(AllowPriv); # for AllowPriv()
AllowPriv("SeDebugPrivilege", 1);

my $dbh = DBI->connect('dbi:WMI:');

my $sth = $dbh->prepare(<<WQL);

SELECT * FROM Win32_Process

print join "\t", "PID", "PPID", "Process";
print "\n";

while (defined (my $row = $sth->fetchrow_arrayref())) {

my $ev = $row->[0];

my $ppid = $ev->{ParentProcessId} || "0";

my $pid = $ev->{ProcessId} || "0";

my $caption = $ev->{Caption} || "<system>";

my $path = $ev->{ExecutablePath} || "<unknown>";

my $cmdline = $ev->{CommandLine} || $caption;

print join "\t", $pid, $ppid, $cmdline;

print "\n";