I tried to execute the batch file using exec command in PHP. I just used it like:
$filename = 'test.bat';
exec($filename);
But didn't get any output. I tried this function with another command, it works fine. Your suggestions would be highly appreciated. Thanks
The main issue was of path
and permission
. I have gotten my batch file to execute.
Here is my solution:
I run my batch file from the same folder the php file is in.
exec("mybatch.bat");
I make sure that Apache Service has enough permission to run the batch file. Just to test i used an administrator account for Apache to log on with.
On Windows server mind the quotes. This is what works for me:
system('cmd.exe /c C:\myfolder\_batches\run_this_batch.bat');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With