in reply to Creating an independent process in Win32

What you're looking for is the Wait method. Here's a little example I whipped up:

use strict; use Win32::Process; my $appname = "c:\\winnt\\notepad.exe"; my $cmdline = "notepad"; my $inherit = 0; my $flags = 'NORMAL_PRIORITY_CLASS'; my $currdir = '.'; my $timeout = 5000; # milliseconds my $ProcObj; Win32::Process::Create($ProcObj,$appname,$cmdline,$inherit,$flags,$cur +rdir) || die &ErrorReport(); $ProcObj->Wait($timeout); print "Done!\n"; sub ErrorReport { print Win32::FormatMessage( Win32::GetLastError() ); }

Replies are listed 'Best First'.
Re: Re: Creating an independent process in Win32
by Hot Pastrami (Monk) on May 08, 2001 at 02:34 UTC
    Thanks for the response, but it seems to have the same behavior as what I already have. What I want it basically to launch the browser in another process entirely, and the script should cease to care what becomes of that other process, finishing it's own execution and exiting normally, whether the browser is still open or not.

    I tried it the way you specified, and I also tried it with $processObject->Wait(0); just as a test, and it did the same thing both times... the script just sits and waits until the browser is finally closed by the user.

    Any other ideas?

    Update: OK, in my attempts, I was just adapting my script to use the same flags and such as yours, and added the Wait() command, and had no success. But when I run yours exactly as you sent it (except changing the path to Notepad to be consistent with Win9x), it works OK. There must be something up someplace else in my code. Thanks for the help, I guess I gotta jusy go through the rest of my script and find the inconsistency.

    Hot Pastrami