I managed to get it working myself, using something like the following code:
open ERROR, ">stderr.txt" or die $!;
open OUTPUT, ">stdout.txt" or die $!;
open SAVEERR, '>&STDERR' or die $!;
open SAVEOUT, '>&STDOUT' or die $!;
STDERR -> fdopen (\*ERROR, "w") or die $!;
STDOUT -> fdopen (\*OUTPUT, "w") or die $!;
$create = Win32::Process::Create($processObj, "program.exe", "-args",
+1, NORMAL_PRIORITY_CLASS, ".");
if ($create != 0)
{
if ($processObj->Wait(60000))
{
$processObj->GetExitCode($result);
}
else
{
$processObj->Kill(999);
}
}