Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
When I run the script the PID is identified it attempts to kill the program, indicated by a delay, then returns 0, indicating that the program has not been killed. I cannot restart the program without killing it first.#!/usr/bin/perl -w use strict; use Win32; use Win32::Process; use Win32::Process::Info; my $execID2find="prog2stopnstart32.exe"; my $pi = Win32::Process::Info->new; my @info = $pi->GetProcInfo(); my @procsOfInterest = grep{ $_->{Name} eq $execID2find } @info; if( @procsOfInterest ) { print "KILL $_->{ProcessId}\n", kill 9, $_->{ProcessId}, for @procsOfInterest; } else { print "No process with the name $execID2find was found\n"; } # Create the process object. my $ProcessObj; Win32::Process::Create($ProcessObj, "C:\\Program Files\\programs\\prog2sto +pnstart32.exe", "prog2stopnstart32", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); $ProcessObj->Suspend(); $ProcessObj->Resume(); # $ProcessObj->Wait(INFINITE); sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: forcible termination of Win32 program then restart
by BrowserUk (Patriarch) on Sep 20, 2006 at 16:39 UTC | |
|
Re: forcible termination of Win32 program then restart
by Anonymous Monk on Sep 20, 2006 at 17:08 UTC | |
by BrowserUk (Patriarch) on Sep 20, 2006 at 17:36 UTC |