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

Hi, I want to kill/stop a process/program called silkperfomer.exe if its running otherwise launch it? Can any Monk will guide me how to do this? Thanks. Forgot to mention that OS is Win XP
  • Comment on How to kill a process/program in Perl??

Replies are listed 'Best First'.
Re: How to kill a process/program in Perl??
by Joost (Canon) on Oct 23, 2006 at 21:32 UTC
Re: How to kill a process/program in Perl??
by GrandFather (Saint) on Oct 23, 2006 at 21:36 UTC

    What OS? Who owns the silkperfomer.exe process and who will own the "killing" process?

    On Windows Win32::Process::KillProcess will do the trick if you have a process ID (see Win32::Process). However you may have trouble finding the pid unless you created the process yourself.


    DWIM is Perl's answer to Gödel
      No one owns the silkperformer.exe. Its independent process. Its load testing tool from segue.
Re: How to kill a process/program in Perl??
by planetscape (Chancellor) on Oct 24, 2006 at 15:44 UTC
Re: How to kill a process/program in Perl??
by yograj (Initiate) on Oct 24, 2006 at 09:57 UTC
    Hi, I am a Linux user and have not worked much on Windows but I have worked on similar project. There is a module "Unix::PID" on CPAN. if($pid->is_pid_running($$)) Before you start with your actual program you can check whether the a program of similar script/program name is running. If yes then exit else continue. So you kill a process by terminating itself. No explicit copmmand is used. I know this is not the ideal soltion but am sure there must be some module in windows too. Yograj.