cutter has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks

Is there a perlish way to list processes running on Win32 systems like the ps command in Unix? I am working on a script to get the PID of a process and kill it using pulist.exe from the W2K resource kit and Win32:Process in perl, but was wondering if there was a way without using pulist.exe. Thanks

Cutter

Replies are listed 'Best First'.
Re: How to ps on Win32 systems.
by tcf22 (Priest) on Sep 04, 2003 at 15:11 UTC
Re: How to ps on Win32 systems.
by BrowserUk (Patriarch) on Sep 04, 2003 at 15:23 UTC

    Take a look in Win32::Process::Info. There is a test script ProcessInfo.pl that comes with the package that will give you a list of the running processes.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.

Re: How to ps on Win32 systems.
by Anonymous Monk on Sep 04, 2003 at 15:10 UTC

    Hi,

    it might be better to use Win32::OLE and the native Win32 WMI component Win32_Process.

    You will be able to use the Windows management components to communicate with workstations that don't have Perl installed. There are several examples on how to do this available on the 'net.

Re: How to ps on Win32 systems.
by true (Pilgrim) on Sep 04, 2003 at 17:07 UTC
    I use the Cygwin ps.exe program.

    I can run it from the commandline inside of my pl's and do damage from there. Cygwin utilities are very portable for win2k and above. I copied the cygwin1.dll and ps.exe into my own perl directory and i am completely portable (optional of course). Perl can kill your pid's with a simple kill statement.

    P.S. cygwin has loads of cool stuff in it. worth exploring in detail.