I am having a very hard time getting an executable to run from within a PHP script (using exec(), or a number of other PHP commands I've tried).
The issue seems to be coming down to a question of user permissions (possibly?) or Windows/server configuration, which I know very little about.
I'm currently testing on Windows localhost, using WAMPserver. I currently have a .bat file with the command to run my executable, just as I would run it from the command line. When running from the command line, the .exe works fine; similarly, when I click the .bat file directly, it starts up and runs the .exe as it should. However, when I try to run it from the PHP script (currently by using exec('open.bat');
, although I've tried numerous other ways of launching it), it activates something called "Windows Interactive Services Detection".
From what I've read, this has something to do with Windows' "sessions", whereby user programs are run in session 1, and system processes are run in session 0, for the sake of security. But for some reason, I'm allowed to run the .bat fine if I simply click on it.
So perhaps it has to do with the user in which PHP is executing the batch file?
I've tried a few methods of running the file as a different user, such as using CPAU, which allows a program to execute under a different user. Again, when clicking on the batch file directly, the program worked fine, but when activating it from PHP, it didn't work (when using CPAU, rather than Interactive Services Detection popping up, it simply didn't do anything).
Has anybody encountered a similar issue while attempting to run an executable from within PHP, or have an idea of how I might get it to run?
notepad.exe example.txt
. Again, when I click directly on the batch file, it opens up 'example.txt' as it should. Yet when I use my PHP script to execute the batch file, the 'Interactive Services Detection' window pops up. So there's some difference in the way the .bat file is run when clicked vs. with PHP that is not allowing things to run properly.