Eric,

This is one way using WMI thru OLE.  This is the simplest way I've
found.  You can find this from the WMI resource kit.

use Win32::OLE qw( in );

my $CLASS =
"winmgmts:{impersonationLevel=impersonate}$Server\\Root\\cimv2";
my $WMI = Win32::OLE->GetObject( $CLASS ) || die Win32::FormatMessage(
Win32::GetLastError() );

foreach my $Proc ( sort {lc $a->{Name} cmp lc $b->{Name}} in(
$WMI->InstancesOf( "Win32_Process" ) ) )
{
      $PID = $Proc->{'ProcessID'}; 
}



-----Original Message-----
From: Eric Hennessey [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, August 31, 2002 4:56 PM
To: [EMAIL PROTECTED]
Subject: Handling running processes


Hi...

Does anyone have a good method for discovering the pid of a running
process? Using the Win32::Process functions, I can create processes and
discover their pids, but I can't figure out how to discover the pid of
an already-running process.

Thanks in advance!
Eric

_______________________________________________
Perl-Win32-Admin mailing list [EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to