Kill a process (Perl)
This code can be found in
Chapter 10 of Windows XP Cookbook
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the Perl code from this site.
# From the book "Windows XP Cookbook"
# ISBN: 0596007256
# ------ SCRIPT CONFIGURATION ------
use Win32::OLE;
$intPID = 2560;
# PID of the process to terminate
$strComputer = '.';
# ------ END CONFIGURATION ---------
print "Process PID: $intPID\n";
$objWMIProcess = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2:Win32_Process.Handle=\'' . $intPID . '\'');
print 'Process name: ' . $objWMIProcess->Name, "\n";
$intRC = $objWMIProcess->Terminate();
if ($intRC == 0) {
print "Successfully killed process.\n";
}
else {
print 'Could not kill process. Error code: ' . $intRC, "\n";
}
|
This code has been viewed 2779 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|