Perl script to KILL process with given name in Windows.
This script is useful as part of any automated process that runs in Windows in order to kill a process with given name.
|
system("WMIC /OUTPUT:C:\\log.txt path win32_process get Processid,Commandline");
$infile1="C:/log.txt";
open(IN1,"<:encoding(UTF-16LE)","$infile1");
$profilename="<PROCESS_NAME>";
while(<IN1>)
{
next if (/^(\s)*$/);#skip blank lines
s/(\s)+$//g; #Removing white space at the end of line.
if (/$profilename/)
{
print "$1\n" if (m/(\d+)$/);
system("taskkill /F /PID $1");
}
}
close(IN1);
|
Thursday, 15 November 2012
Perl script to KILL process with given name in Windows
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment