in reply to find out, if process with $PID exists (under Windows!)
Try something like
#!/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{COMPUTE +RNAME}\\Root\\cimv2"; my $WMI = Win32::OLE->GetObject( $CLASS ) || die "Cannot Get list of P +IDS\n"; foreach my $Proc ( sort {lc $a->{Name} cmp lc $b->{Name}} in( $WMI->In +stancesOf( "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);
Code Ripped from a working script I have running... This peice has not been tested on its own but should work..;-)
Update: Thanks to BrowserUk for reminding me what the question really was..!
-----
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: find out, if process with $PID exists (under Windows!)
by BrowserUk (Patriarch) on Apr 09, 2003 at 14:36 UTC | |
by AcidHawk (Vicar) on Apr 09, 2003 at 14:40 UTC |