perl   windows杀进程

前端之家收集整理的这篇文章主要介绍了perl   windows杀进程前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
use Win32::OLE;
use Win32::Process;
use Cwd;
##下面枚举机器中正在运行的所有进程信息
$wmi = Win32::OLE->GetObject('winmgmts:\\\\.\\root\\cimv2');##两种方法都可以的
$plist = $wmi->InstancesOf("Win32_Process");
my $dir = getcwd;
my $FilePath =$dir."\\杀死进程.txt";
print "file is哈 $FilePath";
my @FileContent = GetFileContent($FilePath);
$n = 0;
foreach $Proc (Win32::OLE::in( $plist )){
print $Proc->{'Name'},".\n";
my $name = $Proc->{'Name'};
my $ID = $Proc->{'ProcessID'};
print $Proc->{'ProcessID'},".\n";
my $test = <STDIN>;
if($name ~~ @FileContent)
{
print $name;
my $test = <STDIN>;
Win32::Process::KillProcess($Proc->{'ProcessID'},0);
}
$n++;
}
sub GetFileContent
{
my $filePath = shift;
if(!-e $filePath)
{
die "the $filePath  does not exits $!";
}
print "is in\n";
open (InputFile,"$filePath" ) || die "can not read file $! \n";
my @InputArray;
while(my $line = <InputFile>)
{
print "the line is $line\n";
my @Temp = split /,/,$line;
push(@InputArray,@Temp);
}
@InputArray;
}

猜你在找的Perl相关文章