#!/usr/bin/perl -W # WMI_for_monks.pl use warnings 'all'; use strict; use Win32::OLE('in'); my ($Machine, $pid_to_kill) = @ARGV; $Machine =~ s{^[\\/]{2,}}{}; my $CLASS = 'WinMgmts:{impersonationLevel=impersonate}!//' . $Machine; my $WMI = Win32::OLE->GetObject( $CLASS ) or die Win32::OLE->LastError(); foreach my $proc (in $WMI->InstancesOf('Win32_Process')){ next unless $proc->{ProcessId} == $pid_to_kill; printf "Killing:%7d\t%s\n", $proc->{ProcessId}, $proc->{Name}; $proc->Terminate(0); }