LOST - Win32::Process

From: RL (lrlemieux_at_hotmail.com)
Date: 01/28/04


Date: Tue, 27 Jan 2004 22:02:01 -0500

Hi all,

I am new and am lost with Win32::Process stuff.

I want on perl script to start a process, then another perl script to
terminate the same process.

I can start a process using...
-------------------------------------------------------
    use Win32::Process;
    use Win32;
    sub ErrorReport{
        print Win32::FormatMessage( Win32::GetLastError() );
    }
    Win32::Process::Create($ProcessObj,
                                "C:\\windows\\system32\\notepad.exe",
                                "notepad temp.txt",
                                0,
                                NORMAL_PRIORITY_CLASS,
                                ".")|| die ErrorReport();
    $ProcessObj->Suspend();
    $ProcessObj->Resume();
    $ProcessObj->Wait(INFINITE);
-------------------------------------------------------
I can search for that process using...
-------------------------------------------------------
use Win32::Process::Info;
$pi = Win32::Process::Info->new();
@pids = $pi->ListPids (); # Get all known PIDs
@info = $pi->GetProcInfo (); # Get the max
%subs = $pi->Subprocesses (); # Figure out subprocess relationships.
for $pid (@info){
   print "-----------------------\n";
   print $pid->{"Name"}."\n";
   print $pid->{"CreationDate"}."\n";
   print $pid->{"ExecutablePath"}."\n";
   print $pid->{"KernelModeTime"}."\n";
   print $pid->{"MaximumWorkingSetSize"}."\n";
   print $pid->{"MinimumWorkingSetSize"}."\n";
   print $pid->{"ProcessId"}."\n";
   print $pid->{"UserModeTime"}."\n";

  if ("$pid->{\"Name\"}" eq "notepad.exe") {
     $gotit = $pid->{"ProcessId"};
     print("Found notepad.exe with pid $gotit\n");
  }
}
-------------------------------------------------------
So what is the next step to actually terminate it?

Thanks in advance :)



Relevant Pages

  • LOST - Win32::Process
    ... I am new and am lost with Win32::Process stuff. ... I want on perl script to start a process, ... for $pid { ... So what is the next step to actually terminate it? ...
    (perl.beginners)
  • LOST - Win32::Process
    ... I am new and am lost with Win32::Process stuff. ... I want on perl script to start a process, ... for $pid { ... So what is the next step to actually terminate it? ...
    (comp.lang.perl.modules)
  • Re: LOST - Win32::Process
    ... > I want on perl script to start a process, ... > terminate the same process. ... (where $pid is the PID of the process you want to murder, ... will be set to the exitcode of the terminated process). ...
    (comp.lang.perl.modules)
  • Re: LOST - Win32::Process
    ... > I want on perl script to start a process, ... > terminate the same process. ... to get drunk and croon as much as they like. ...
    (perl.beginners)
  • Re: Terminate the entire Perl script when control_C in an application
    ... I wrote a Perl script. ... application is running or is waiting in the license queue, ... Control_C would terminate the application. ... This is probably OS dependent, as on Linux, upon a Ctrl-C a SIGINT is ...
    (comp.lang.perl.misc)