LOST - Win32::Process

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RL

    LOST - Win32::Process

    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::FormatMe ssage( Win32::GetLastE rror() );
    }
    Win32::Process: :Create($Proces sObj,
    "C:\\windows\\s ystem32\\notepa d.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->{"ExecutablePa th"}."\n";
    print $pid->{"KernelModeTi me"}."\n";
    print $pid->{"MaximumWorki ngSetSize"}."\n ";
    print $pid->{"MinimumWorki ngSetSize"}."\n ";
    print $pid->{"ProcessId"}. "\n";
    print $pid->{"UserModeTime "}."\n";

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

    Thanks in advance :)


  • eokyere
    New Member
    • Sep 2005
    • 1

    #2
    terminate = kill

    hth,
    eokyere

    Comment

    Working...