csotzing has asked for the wisdom of the Perl Monks concerning the following question:
I need the full name, so that I can distinguish between different perl and/or java processes that are running--so I know what to kill and what to leave alone. Any help is appreciated!# Name: _getProcessesWin32 # Desc: gets ids and names for currently running processes on Win32 pl +atforms # In: None # Out: hash of process id, name pairs sub _getProcessesWin32 { my (%counter,%rCounter,%processList); Win32::PerfLib::GetCounterNames('',\%counter); %rCounter = reverse(%counter); # Get id for the process object and process counter my $processObj = $rCounter{'Process'}; my $processId = $rCounter{'ID Process'}; # create connection to local computer my $perfLib = new Win32::PerfLib(''); my $procRef = {}; # get the performance data for the process object $perfLib->GetObjectList($processObj, $procRef); $perfLib->Close(); # get current processes my $instanceRef = $procRef->{'Objects'}->{$processObj}->{'Instances' +}; foreach my $instance (values %{$instanceRef}) { my $counterRef = $instance->{'Counters'}; foreach my $counter (values %{$counterRef}) { if($counter->{'CounterNameTitleIndex'} == $processId) { my $pid = $counter->{'Counter'}; $processList{$pid} = $instance->{'Name'}; } } } return %processList; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32 Process name with arguments
by traveler (Parson) on Sep 06, 2002 at 18:55 UTC | |
|
Re: Win32 Process name with arguments
by Marza (Vicar) on Sep 06, 2002 at 20:09 UTC | |
by csotzing (Sexton) on Sep 09, 2002 at 12:32 UTC |