#!/usr/bin/perl use strict; use warnings; use Win32::OLE qw( in ); use Win32::OLE::Variant; use Win32::Process; my $CLASS = "winmgmts:{impersonationLevel=impersonate}\\\\$ENV{COMPUTERNAME}\\Root\\cimv2"; my $WMI = Win32::OLE->GetObject( $CLASS ) || die "Cannot Get list of PIDS\n"; foreach my $Proc ( sort {lc $a->{Name} cmp lc $b->{Name}} in( $WMI->InstancesOf( "Win32_Process" ) ) ) { if ($Proc->{Name} eq "Whatever you are looking for.exe") { print "$Proc->{ProcessID} is STILL RUNNING\n"; # We Dont Want to KILL the PID ---Win32::Process::KillProcess($Proc->{ProcessID}, 5); # Other Processing Here..;-) } } #### use Win32::process; Win32::Process::KillProcess($PID,5);