# 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"
);
}