views:

15

answers:

1

In PHP I am using proc_open to run a command at the command line.

It needs to open in a new CMD window, so I prepended 'start' to the beginning of the command.

However, it also needs to stay open to display the results, but actually it closes the window automatically afterwards.

I have tried adding 'pause' and also the /k option to 'remain'. But neither work. The window just shuts.

How can I make the window stay open when using proc_open?

This is part of the code, $cmd is filled earlier:

$descriptorspec = array(
  1 => array('pipe', 'w'), // stdout
  2 => array('pipe', 'w'), // stderr
);

$process = proc_open($cmd, $descriptorspec, $pipes);
if (!is_resource($process))
{
  throw new RuntimeException('Unable to execute the command.');
}

stream_set_blocking($pipes[1], false);
stream_set_blocking($pipes[2], false);
A: 

"start" will fire up the specified command and then exit. It's basically asynchronous. You might have better luck having your proc_open start a cmd shell which runs a batch file, and run your command from inside the .bat, after which you can do a 'pause'

Marc B
Sounds good, thanks.
Dave