Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to terminate a running process

Status
Not open for further replies.

Cambridge10

Programmer
May 5, 2008
18
NL
Code:
system ("mbrola $db extern.pho extern.wav");
system ("bruceplayer.exe extern.wav");

Extern.wav has a duration of ten minutes. I've created a Stop button so that the user can stop bruceplayer.exe anytime.
How can I terminate this process?
 
What I do:

my $Machine = "\\\\.";

#get wget PID on my machine
my $CLASS = "winmgmts:{impersonationLevel=impersonate}$Machine\\Root\\cimv2";
my $WMI = Win32::OLE->GetObject( $CLASS ) || die;

foreach $Proc ( in( $WMI->InstancesOf( "Win32_Process" ) ) ) {
$PROCNAME = $Proc->{Name} ;
$PID = $Proc->{ProcessID};
if ( $PROCNAME =~ /extern.wav/) {
kill 9 => $PID if ($PID);
}
}

Long live king Moshiach !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top