in reply to Windows - Find Process by Name

Use Win32::PerfLib, that should be included in for instance ActiveState perl. :)
You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

Replies are listed 'Best First'.
Re: Re: Windows - Find Process by Name
by RMGir (Prior) on Apr 19, 2002 at 13:31 UTC
    It's not clear from the Win32::PerfLib docs, but if you execute the sample snippet,
    use Win32::PerfLib; my $server = ""; Win32::PerfLib::GetCounterNames($server, \%counter); %r_counter = map { $counter{$_} => $_ } keys %counter; # retrieve the id for process object $process_obj = $r_counter{Process}; # retrieve the id for the process ID counter $process_id = $r_counter{'ID Process'}; # create connection to $server $perflib = new Win32::PerfLib($server); $proc_ref = {}; # get the performance data for the process object $perflib->GetObjectList($process_obj, $proc_ref); $perflib->Close(); $instance_ref = $proc_ref->{Objects}->{$process_obj}->{Instances +}; foreach $p (sort keys %{$instance_ref}) { $counter_ref = $instance_ref->{$p}->{Counters}; foreach $i (keys %{$counter_ref}) { if($counter_ref->{$i}->{CounterNameTitleIndex} == $proce +ss_id) { printf( "% 6d %s\n", $counter_ref->{$i}->{Counter}, $instance_ref->{$p}->{Name} ); } } }
    it gives you a process list.
    --
    Mike