http://www.perlmonks.org?node_id=143343


in reply to Using Win32::Process to prevent timeouts

The only time I've ever used Win32::Process is when I wanted to test whether I could connect to a remote resigtry. What would happen is that on some machines, it would hang and the script would basically stop.

I'm not sure what exactly you want to do, but Win32::Process is basically going to launch another application from your script. Here's what I did to launch a perl one-liner to test whether or not the connection attempt would hang.

sub RegConnect { my ($pObj, $ExitCode); my $comp = shift; my $pString = "perl -MWin32::TieRegistry -e " . '"' . '$Registry->Connect(' ."'" . $comp . "', 'LMachine');" . '"'; Win32::Process::Create($pObj, "c:\\perl\\bin\\perl.exe", $pString, 0, NORMAL_PRIORITY_CLASS, ".")|| die "Can't create Perl Process: $!\n"; $pObj->Wait(7000); $pObj->GetExitCode($ExitCode); if ($ExitCode) { $pObj->Kill(1); return 0; } return 1; }
Hope that's helpful,
Rich