LOST - Win32::Process

Discussion in 'Perl' started by RL, Jan 28, 2004.

  1. RL

    RL Guest

    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 :)
     
    RL, Jan 28, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rtm
    Replies:
    0
    Views:
    804
  2. Java and Swing
    Replies:
    1
    Views:
    685
    Chris Lambacher
    Oct 24, 2005
  3. Tim Golden
    Replies:
    0
    Views:
    444
    Tim Golden
    Oct 21, 2005
  4. Qi Lu
    Replies:
    0
    Views:
    410
    Qi Lu
    Jul 14, 2008
  5. Mike Stead
    Replies:
    3
    Views:
    275
    Roger Pack
    Mar 25, 2010
Loading...

Share This Page