user1249555
user1249555

Reputation: 31

Why does PHP exec() command launch a DOS window? Can I hide this?

I am executing a PHP script as a cgi-script on Windows XP, web server is Apache 2.2 which is encrypted using phtmlenc(). This is opening a blank DOS prompt (cmd.exe window) during execution.

This the test script test.php I have placed my script inside cgi-bin directory:

#! C:/PHP/bin
exec(WHOAMI);

When I launch the script through Internet Explorer by typing localhost/cgi-bin/test.php I can see a DOS window popup.

  1. Can I suppress this by changing Apache configuration or PHP configuration?
  2. The original script is encrypted using a phtmldec() and hence I cannot change the actual exec() call
  3. Can I edit the PHP to put some headers to hide or suppress the DOS window?

Upvotes: 3

Views: 719

Answers (1)

Jon
Jon

Reputation: 437336

You cannot hide the window because that is under the control of the operating system, not PHP or Apache. And since whoami is a console application it creates a console when run.

By the way, 'WHOAMI' should be in quotes.

Upvotes: 1

Related Questions