Hi all-
I have a script that gets the process name of currently running Win32 processes... BUT I can't figure out how to get the command-line arguments for that process (so that it will resemble the name in a ps command on Unix)
For example, if I have "perl temp.pl" running on Win32, I can get the process's name as "perl", but I can't figure out how to get the process's name as "perl temp.pl". I'm using Win32::PerfLib to get the process ids and names:
# 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; }
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!
-C
print(map(lc(chr),split(6,qw/99672682673683684689632658645641610607/)));

In reply to Win32 Process name with arguments by csotzing

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.