LOST - Win32::Process

R

RL

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");
}
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top