Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Getting a list of all running apps/processes in Win32 then shutting down a given process

by dmtelf (Beadle)
on Jul 26, 2000 at 16:14 UTC ( #24468=perlquestion: print w/ replies, xml ) Need Help??
dmtelf has asked for the wisdom of the Perl Monks concerning the following question:

O Wise Perl-fluent Monks,

I need to get a list of all running apps/processes (under Win98) and offer the user the option of shutting down one of the processes (by entering its ID).

I've done some research on PerlMonks, but it seems that existing answers are for Unix boxen, which support fork() etc which apparently ActivePerl 522 does not support.

Do any wise Monks out there know how to do this on Win32?

dmtelf

Comment on Getting a list of all running apps/processes in Win32 then shutting down a given process
(jcwren) Re: Getting a list of all running apps/processes in Win32
by jcwren (Prior) on Jul 26, 2000 at 16:50 UTC
    Check out the Win32::Process module. There was a good thread on using this module a little while ago, somewhere around here. I can't find the thread, but it made some good points. Sometimes trying to find old material on the site is difficult. A wide-area search would be really *cool*...

    --Chris

    e-mail jcwren
Re: Getting a list of all running apps/processes in Win32 then shutting down a given process
by gaggio (Friar) on Jul 26, 2000 at 18:50 UTC

    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://24468]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2014-08-20 23:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (125 votes), past polls