in reply to Re: How to kill a windows process by command name?
in thread How to kill a windows process by command name?
You could replace the use of Win32::Process with a call to perl's built-in kill using a signal value of 2 (or 21 or -9 work, as do many others).
use strict; use Win32::Process::Info; Win32::Process::Info->Set(variant=>'WMI'); my $pi = Win32::Process::Info->new(); for($pi->ListPids){ my ($info) = $pi->GetProcInfo($_); if($info->{CommandLine} eq 'perl foo.pl a'){ my $obj; my $pid = $info->{ProcessId}; kill 2, $pid; print "Killed $pid\n\n"; } }
|
|---|