1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use strict;
use warnings;
use Win32;
use Win32::Process;
$| = 1;
my ($process, $exitcode, $pid);
print "Starte ping ..\n";
Win32::Process::Create(
$process,
"C:\\windows\\system32\\ping.exe",
"ping -n 5 127.0.0.1",
0,
NORMAL_PRIORITY_CLASS,
'.',
) or die Win32::FormatMessage( Win32::GetLastError() );
print "Warte max 10 Sekunden auf ping\n";
for (1 .. 10) {
print;
$pid = $process->GetProcessID();
$process->GetExitCode($exitcode);
print " EC-Schleife = $exitcode,\tPID = $pid\n";
sleep 1;
$exitcode = undef;
$pid = undef;
}
$process->Kill(99)
or die "Kann Prozess nicht killen '$process'";
$process->GetExitCode($exitcode);
print " Exitcode Ende = $exitcode\n";