Ads

Monday, 30 September 2013

How to execute batch file via PHP?

The main issue was of path and permission. I have gotten my batch file to execute.
Here is my solution:
  1. I run my batch file from the same folder the php file is in.
    exec("mybatch.bat");
  2. 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.

2 comments:

  1. Thank you! But exec should be accessable to run.

    ReplyDelete
    Replies
    1. Yes, exec is use for the run. Here exec function is use for the run/execute/run the .bat file.

      Delete