On Thu, 22 Nov 2007, Kenneth Ölwing wrote:
> 
> >   system "\"C:\\Programme\\Internet Explorer\\iexplore.exe\" $website";
> > wait, until the browser window is closed.
> Some:
> 
> Look into Win32::Process (I believe it's called). The CreateProcess call
> has flags to control this.
> 
> Crude, but since you're using 'system', run cmd.exe and there use the
> 'start' command.

Just remember that the start command treats a quoted string as a title
for the new window, so if you are quoting the path to the executable,
add an empty argument in front:

    start "" "c:\my folder\my app.exe"
 
> Forget the package, but search for ShellExecute($website) - basically,
> this will launch the users choice of browser rather than forcing IE on them.

The "start" command in cmd.exe is the commandline interface to ShellExecuteEx(),
so unless you need to specify any other parameters, you can just use "start".

> I believe there's some mumbo-jumbo by having '1', as the first param,
> ie. 'system(1, "command...), to get the effect but  I can't remember the
> details.

Yes, that runs the program asynchronously and returns the pid.  Remember to
wait() or waitpid() for it, or you will eventually run out of process handles
(you have about 63, and they will be shared with pids used for the fork()
emulation):

    my $pid = system(1, "myapp.exe @args");
    # do some stuff ...

    # now wait until myapp.exe has terminated
    waitpid($pid);

Note that you must not use shell meta-characters in the commandline
with system(1, ...) because Perl will then start the command indirectly
via cmd.exe, and the $pid will be the pid of cmd.exe and not of your
actual app.

Cheers,
-Jan

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to