Re: End a process in the Task manager
by Amar (Sexton) on Jun 03, 2005 at 07:39 UTC
|
Use WIN32::Process::Info and get process ID, then use the process ID to kill it like below
Win32::Process::KillProcess($pid,0);
make sure u know what u r trying to kill.
Hope this will give u an idea
| [reply] [d/l] |
|
|
Thanks for the reply. Can I install WIN32::Process::Info and Win32::Process::KillProcess using ppm? if so please give me the repository url from where i can install it.
| [reply] |
|
|
ppm> search Win32::Process::Info
Searching in Active Repositories
1. Win32-Process-Info [1.005] Get information on arbitrary processes
+ in Windows NT
ppm> describe 1
====================
Package 1:
Name: Win32-Process-Info
Version: 1.005
Author: Tom Wyant (wyant@cpan.org)
Title: Win32-Process-Info
Abstract: Get information on arbitrary processes in Windows NT
Location: bribes
Available Platforms:
1. MSWin32-x86-multi-thread
2. MSWin32-x86-multi-thread-5.8
====================
ppm> rep describe bribes
Describing Active Repository 8:
Name: bribes
Location: http://www.bribes.org/perl/ppm/
Type: Webpage
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
| [reply] [d/l] |
|
|
|
|
|
Re: End a process in the Task manager
by spurperl (Priest) on Jun 03, 2005 at 07:24 UTC
|
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. | [reply] |
|
|
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.
| [reply] [d/l] |
|
|
I don't have the full code, but the EnumWindows API function may be of help.
| [reply] |
|
|
|
|
|
|
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?
| [reply] |
|
|
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.
| [reply] |
| A reply falls below the community's threshold of quality. You may see it by logging in. |