PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
The code always says it's working, but the .bat is not running. I have checked the .bat file and it works fine at the command line. I have used this exact code on my WAMP box (php 5.0.3) and it works fine.
I have tried changing exec("C:\Flash.bat") to exec("cmd.exe /c C:\Flash.bat") as this has been suggested in the past when running on IIS, but it didn't make any difference.
Can anyone think of anything else? PHP.ini setting or IIS setting maybe? Or even another way of coding it?
Thanks
Thanks Andy. I have tried everything on that page and none of it worked. I guess it must be either a permissions / user problem or a problem with IIS. The pain of it is it dosen't return any errors, it just says it works!
Does the user have "execute" permission in that directory where the bat file resides? If it only had "read" or "read/write" permission the the script cannot execute a file of any type, and I think system() would not return anerror under that circumstance.
I'm not real expert on servers, so I don't know for sure who has to have the permission. System, owner, user...
Cheers for your help! I have echoed the command and it looks fine, i then ran that command from the command line in the same directory (that was echoed) and the .bat ran fine. IIS is using anonymous access and I have added the user id used for this to the administrator group. I have now added full control access rights for administrators to the entire C: drive and still no joy.
Looks like it's not going to work, which is a bummer, as being able to do this simple operation would have saved the company a lot of money.
If anyone can think of anything please let me know!
I have some spare time today and am looking at this again. I ran the above and it displays the command line followed by a 1. As this code on my WAMP display the command line and then a 0 I guess it is returning an error on the IIS server. Reading the manual it says the 1 indicates the command did not execute successfully, does anyone have any ideas how I can find out what this error is?
(Sorry I didn't read that post properly the first time, was a bit hot headed that day!)
Well, all it tells you is that system() ran but that the batch file did not. Since the batch file is not returning an error code, and presumably would not do so even if it did run, then system() can't tell you much other than that the called process did not run. It could still be a permissions problem, since command line and PHP are not the same user. PHP is usually user "99" on a shared Unix server, at least it is on mine, so you might see if that user has execute permission.