Calling application (.exe) from PHP on XP

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I am trying to call an application from php.  I have tried exec() and
system() and even popen() all to no avail.

Can an application be called if it brings up a window?  The app I am
calling has a command line interface, but it insists on bringing up
it's standard window also.

At the moment the .exe file displays in Windows Task Manager in the
Processes tab.

The PHP script hangs (until timeout) and the .exe doesn't do the job it

I am probably being daft :o)

Thanks in advance for any help or tips,
Mike Youell.

Re: Calling application (.exe) from PHP on XP

Maybe this passage in the exec() manual contains your answer?

Note: If you start a program using this function and want to leave it
running in the background, you have to make sure that the output of
that program is redirected to a file or some other output stream or
else PHP will hang until the execution of the program ends.

Mike Youell wrote:
Quoted text here. Click to load it

Re: Calling application (.exe) from PHP on XP

Hi Gerry,

Thanks for your help.

I piped the output to NUL and later to a file but it still didn't work.

I think it's an XP problem, probably to do with permissions or
something, but no log file info so it's just complete guess work.

I tried everything suggested on news groups (going back a few years)
and on websites, and asked a highly experienced friend yet nothing

So in the end I created a listener "process" (actually a 15 line DOS
batch file for now) external to PHP which listens for system events
triggered by PHP, i.e. PHP creates a file which the listener process
uses to call the relevant application.  The file is deleted once
processed by the listening batch file.

I've put some simple handshaking in there so PHP can talk to the
listener process.

Anyway I've sorted it.  Not perfect but then what is ;o)

Again, thanks for your help :o)

Mike Youell.

Re: Calling application (.exe) from PHP on XP

Mike Youell wrote:
Quoted text here. Click to load it

PHP executes in context of IIS (or other webserver), that means it has
less privileges and usually cannot interact with the desktop.

IIS has settings in Control Panel -> Administration Tools -> Services ->
World Wide Web Publishing -> Log On tab -> Allow service to interract
wiht desktop.


Re: Calling application (.exe) from PHP on XP

Thanks Roman.  I'm using Apache so not sure what to do about
permissions, or whether it is to do with permissions?

I'm also a bit nervous to reduce permissions anyway.  The system I
created (see above) I believe to be more secure as it only allows
specific executables to be called with certain arguments only, and it
doesn't relax any permissions, which makes it a little bit easier to
sleep at night :o)


Site Timeline