I am using wamp on a windows machine and just wanted to invoke an exe on this via a php web page. When I am launching the php from commandline on server its working fine but when invoke same php via browser from other machine it does not work and waits forever. My php file is like this

<?php 
 exec("calc.exe");
?>

When I access this from client (http://servername/exec.php) it waits forever. I know its a permission issue with apache on windows, but not sure how to fix this.

link|improve this question
Do your error logs have anything interesting to say ? – Iain Jan 11 at 10:05
feedback

1 Answer

It won't work.

As you are running Apache as a Windows service, which runs on different logon session, it will not show the application windows. Also, the application will run on the webserver system only and not on the system where you are accessing the php file through browser.

As the calculator application is waiting for user input, the php file is loading forever in your system.

You can initiate console based applications using "exec" function.

link|improve this answer
That doesn't seem to hold true - I have Apache setup as a service (with XAMPP) on Windows 7, and can launch 'calc.exe' without any issue via PHP run from my browser. – cyberx86 Jan 11 at 11:17
Thanks, Yes it clears many things. By "console based" applications did you meant that I can initiate any batch script via exec which in-turn do some other stuffs? If that's possible that would be great! I have tried running a batch script via exec on server but again i am seeing same forever wait. – Anindya Sharma Jan 11 at 11:30
Yes, you can run a batch script. But the batch script should not start any console based application. – Aravind Jan 11 at 12:21
@cyberx86 I am also running Apache as a service (via net start wampapache) , but its not working for me. I have also made the service log on as an administrator account. – Anindya Sharma Jan 11 at 13:00
The service won't start any console based application. If you are running a service in local system account, you can enable "Allow service to interact with desktop" option to start the application in desktop. But, it will start at the system at where the webserver service is running. – Aravind Jan 11 at 13:45
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.