Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

How can I see/manage the process list on Win32?

( #24585=categorized question: print w/ replies, xml ) Need Help??
Contributed by Russ on Jul 27, 2000 at 01:39 UTC
Q&A  > programs and processes


Description:

How can I see/manage the process list on Win32?

I'd like to find and kill a process.

Answer: How can I see/manage the process list on Win32?
contributed by gaggio


To get the process list (a hash with the pids as a key, use my function). As said before, this function works for the local machine or for a remote machine - just give the ip you want (127.0.0.1 for the local machine).

Then you can just find the pid you want to kill (by doing a search on the processes names, probably) and use the function Win32::Process::KillProcess, like this:

my $actually_killed = Win32::Process::KillProcess($pid,0);
Please note that you should check that the function is returning the pid you killed, to test if it did it OK.
Answer: How can I see/manage the process list on Win32?
contributed by talexb

As an addendum to gaggio's answer, please note that this works only on Windows ME, 2000 and NT and does not work for Windows 95 or 98, probably due to differences in architecture.

Answer: How can I see/manage the process list on Win32?
contributed by machinecraig

This is not a perl solution, but I've had very good sucess with using a tool from the guys at Sysinternals. Check out their psutils. In their utility package, pslist.exe will most likely do everything you need.

Another great solution is to check out the GNU Utilities that have been blessed with Windows ports. There's also probably, almost definitely, a ResKit utility. I know none of these solutions are perlish, but IMHO - it makes more sense to call a small executable then to have to write up an implementation of ps.

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (18)
    As of 2014-10-21 12:48 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (103 votes), past polls