Use Perl to Kill Lotus Notes Processes on Windows

 
 
 
 
# Recently, I experienced Notes crash problems several times. 
# It wasted me a lot of time to terminate Notes completely and then restart it,
# so I wrote this Perl script to save myself. Also hope it's helpful to you when you read these comments :-)
# author: think.hy@gmail.com
# date: 5/3/2013
#! perl
 
use warnings ;
use strict ;
 
use Win32:: OLE qw(in) ;
use Win32:: Process ;
 
sub matching_processes {
my ( $pattern ) = @_ ;
 
my $objWMI = Win32:: OLE -> GetObject ( 'winmgmts://./root/cimv2' );
my $procs = $objWMI -> InstancesOf ( 'Win32_Process' );
 
my @hits ;
foreach my $p ( in $procs ) {
push @hits => [ $p -> Name , $p -> ProcessID ]
if $p -> Name =~ /$pattern/ ;
}
 
wantarray ? @hits : \ @hits ;
}
 
my $notesStyle = qr/(notes.exe)|(nlnotes.exe)|(ntaskldr.exe)|(nminder.exe)|(nsd.exe)/ i ;
 
foreach ( matching_processes $notesStyle )
{
my $name = $_ -> [ 0 ];
my $pid = $_ -> [ 1 ];
 
print "Name: $name\tPID: $pid \n" ;
#Win32::Process::KillProcess($pid, 0);
system ( "TASKKILL /F /T /PID $pid" );
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值