in reply to find PID for a process/executable running on Win32
How much easier do you want it :)
#! perl -slw use strict; use Win32::Process::Info; print "My pid: $$"; my $pi = Win32::Process::Info->new; my @info = $pi->GetProcInfo(); my @procsOfInterest = grep{ $_->{Name} eq $ARGV[ 0 ] } @info; if( @procsOfInterest ) { print "A process with the name $ARGV[ 0 ] was found with pid:", $_->{ProcessId} for @procsOfInterest; } else { print "No process with the name $ARGV[ 0 ] was found"; } __END__ P:\test>381203 perl.exe My pid: 1184 A process with the name perl.exe was found with pid:1184 P:\test>start /b perl -le"sleep 60; print 'Bye'" P:\test>381203 perl.exe My pid: 340 A process with the name perl.exe was found with pid:1600 A process with the name perl.exe was found with pid:340
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: find PID for a process/executable running on Win32
by Anonymous Monk on Aug 09, 2004 at 13:22 UTC |