Reputation: 5028
I'm running Apache 2.2.17 and PHP 5.3.5 on a Windows 7 64-bit machine.
I have noticed that if I try to use exec(), system() or any of the other functions for executing a system command through PHP it does not work. The exact same commands will work if you paste them into the command line window. This seems to affect all programs which are not the simplest of command line programs. Even a simple attempt to open notepad will not work e.g. system('C:/Windows/system32/notepad.exe').
What could be causing this?
Thanks
Upvotes: 2
Views: 4094
Reputation: 5028
Unfortunately none of these solutions worked for me. I have changed my approach and will not be using PHP to launch the executable.
Upvotes: 0
Reputation: 7762
Read it
E.g.
<?php exec('C:\\WINDOWS\\system32\\psexec.exe \\192.168.1.224 -u myuser ... etc.
I also see the following in the referenced discussion:
quote; In Windows, exec() issues an internal call to "cmd /c your_command". This implies that your command must follow the rules imposed by cmd.exe which includes an extra set of quotes around the full command:
Current PHP versions take this into account and add the quotes automatically, but old versions didn't. endquote:
There is also some discussion about setting the Windows permissions on the folder where the command resides, which I can imagine could be quite the heartburn on a Vista or Windows 7 machine. You may need to allow access to the WAMPserver itself somehow.
EDIT:
The only other suggestions I can think of are:
grant FULL access to EVERYBODY on the executable file AND the folder path that contains it
check the server error log to see if there's an error message with any useful information
one more thing occurs to me:
good luck!
Source(s): Recommended reading: a lot of people discuss the solutions to a lot of problems
http://php.net/manual/en/function.exec.php
Upvotes: 1