in reply to Re: Re: Win32::Process::KillProcess
in thread Win32::Process::KillProcess
Update: Simplified for loop to only focus on name and Pids#!/usr/local/bin/perl use strict; use warnings; use Win32::Process; use Win32::Process::Info; my $Process_Obj = Win32::Process::Info->new (undef , "NT"); my @info = $Process_Obj->GetProcInfo (); my $Pid; my $Name; my %Process; for my $i ( 0 .. $#info ){ $Pid = $info[$i]{"ProcessId"}; $Name = $info[$i]{"Name"}; print "$Pid \t $Name \n"; $Process{$Pid} = $Name; } print "What program do you want to kill?\n"; my $exit_code = 1; my $kill = <STDIN>; chomp $kill; Win32::Process::KillProcess($kill, $exit_code)
If you give more specifics I can show more specific examples this is done in a way to show where the PID can come from.
Update: I am trying to simplify the id, in your intial post you did not show where your PID was coming from. For this to work we need to know how you are determining the pid to kill. In this example I am printing a list and having the user choose but the same information can be used programatically to kill processes. I tend to search for a name and kill all instances of that name. But again this is just an example. If you need any more info just describe what you are doing with a bit more detail and I will try to help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Win32::Process::KillProcess
by jimbobfurley (Novice) on Dec 23, 2003 at 20:14 UTC | |
by Ninthwave (Chaplain) on Dec 23, 2003 at 21:54 UTC |