Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Win32 Process Info

by demerphq (Chancellor)
on Apr 19, 2002 at 14:08 UTC ( [id://160544]=CUFP: print w/replies, xml ) Need Help??

Uses pslist from the open source pstools suite from to produce a hash containing current process data.

Takes a set of key,value pairs. Currently accepts 'process' and 'machine' keys. Will extend with additional pslist options at a later date. NOTE, leading \\ on machine name is optional, and process name should not have an extension.

There probably is a better way to do this, but this tool works on local and remote machines and its really easy to use...


Or maybe that isnt the best excuse?

use strict; use warnings; use constant Process_EXE => 'pslist.exe'; sub process_hash { my %params=@_; my $find_process=quotemeta($params{process}||""); my $machine =($params{machine}||""); $machine="\\\\".$machine if $machine && $machine!~/^\\\\/; open my $process,"pslist.exe $machine |" or die " Cant open pstool +s!"; my %processes; my @field_names=("Name","Pid","Pri","Thd","Hnd","Mem","User Time", +"Kernel Time","Elapsed Time"); while (<$process>) { chomp; my @process_data=split/\s+/; next unless @process_data==9; if ($process_data[1]=~/pid/i) { next } else { my %process; @process{@field_names}=@process_data; $processes{$process_data[0]}=\%process; return \%process if $process_data[0]=~/^$find_process$/i; } } return $find_process ? undef : \%processes; } use Data::Dumper; # All processes on local machine print Dumper(process_hash()); # Process info about explorer print Dumper(process_hash(process=>'explorer')); # Process list from a remote machine print Dumper(process_hash(machine=>'brahma'));

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://160544]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-13 21:12 GMT
Find Nodes?
    Voting Booth?

    No recent polls found