in reply to End a process in the Task manager

Perl doesn't have built-in utilities for this, but you have several options.

(1) You can use the "taskkill" command line utility on Win XP or download a similar one from the net. Then, perl can call it using "system".

(2) You can use the Win32::API bindings of Perl to call the Win32 API function to enumerate all tasks / windows and send WM_CLOSE messages to them.

Replies are listed 'Best First'.
Re^2: End a process in the Task manager
by Nalina (Monk) on Jun 03, 2005 at 10:19 UTC
    Thank u very much. If I were to use Win32::API how will i get the process id? If I do
    use Win32::API; Win32::API->Import("kernel32", "int GetCurrentProcessId()"); $PID = GetCurrentProcessId();
    I get the process id of the current process. But what if I want to kill some other process? For example If I open an Excel application and want to forcefully kill that process, how do i get the PID of it.
    Please send me some sample code to do it.
      I don't have the full code, but the EnumWindows API function may be of help.
        how do I use Enum Windows API function in perl?
Re^2: End a process in the Task manager
by Nalina (Monk) on Jun 03, 2005 at 08:48 UTC
    Thaks for the reply.
    I am running windows 2000 professional. which utility can I use instead of "taskkill" for windows 2000 professional & windows 2000 server?
      If this is your preferred solution, just google "taskkill windows 2000" and you'll find tons of links / information. There are donwloadable tools there too.