Christian Christian - 1 month ago 11
PHP Question

PHP Show CMD Command Prompt Window (Windows)

Usually, you would want to hide the CMD window.
In my case, I'll be doing some tests with PHP+CLI.
It will be mighty useful if PHP could be made to launch a CLI popup.
But alas, I can't find a way to make it to.

The following command should have made it work, but it doesn't:

START "PHP AE2" CMD /K DIR


The PHP code in question is based on
proc_open()
:

$proc=proc_open($cmd,array(
0=>array('pipe','r'), // STDIN
1=>array('pipe','w'), // STDOUT
2=>array('pipe','w') // STDERR
),$pipes);
// ....some stream stuff....
$return=proc_close($proc);


Although the command runs fine, the popup doesn't show up. I suspect this is a feature of Apache. Is there a way to completely detach the CMD from its parent?

Also, I'll be substituting
DIR
with a small script/batch/program that initializes the environment, so it is important that I can execute a program after the popup shows up.

(This is mostly for educational purposes and won't follow into production.)

Abs Abs
Answer

I am bit late to answering this question, but to help close this question here is my answer.

The command is correct but you need to get Apache to interact with the desktop. If you are on a windows machine, just go to services, find Apache and make sure you tick the "Allow Service to Interact with desktop" checkbox.

Comments