0

I am trying to have a PHP file call a Windows batch script using

exec("runPy.bat");

I have also tried

exec("cmd /c \\server\somePath\runPy.bat");

It doesn't matter what I try, the batch script doesn't work. And I don't get any errors. After much research I found a post saying that the problem may be due to privaleges: https://stackoverflow.com/a/11613662

Can anyone show me safe/proper way to set up permissions so that I can call batch scripts in IIS? Or is it unsafe in general to do that? Using IIS8 if that helps.

sdMarth
  • 521
  • 1
  • 8
  • 15

1 Answers1

0

To run batch, you need to use cmd, which you can call via:

system("cmd /c C:[path to file]");
syntaqx
  • 2,636
  • 23
  • 29
  • that does the same thing as exec for me. The script isn't run but I don't get any errors. – sdMarth Jan 24 '19 at 17:12
  • Try grabbing the entire output with `exec("cmd /c C:[path to file]", $output)` by passing the second argument and see what the entire thing is giving you. If you're getting literally nothing back, it's probably a path or permission issue. Be sure PHP has the ability to run the script, as it's probably only accessible by your user, and PHP isn't running as your user. – syntaqx Jan 24 '19 at 17:38