1

PHP では、コマンド ラインでコマンドを実行するために proc_open を使用しています。

新しい CMD ウィンドウで開く必要があるため、コマンドの先頭に「start」を追加しました。

ただし、結果を表示するために開いたままにする必要もありますが、実際には後で自動的にウィンドウを閉じます。

「一時停止」と「残り」に /k オプションを追加してみました。しかし、どちらも機能しません。窓が閉まるだけです。

proc_open を使用しているときにウィンドウを開いたままにするにはどうすればよいですか?

これはコードの一部です。$cmd は前に入力されています。

$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);
4

1 に答える 1

1

"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'

于 2010-09-01T14:27:12.113 に答える