0

I believe my goal should be sort of simple, but being somewhat new to server admin I am coming to a halt. My goal, be able to execute a .bat file located on one of my remote servers by clicking a button on a page in the Admin section of my website. My website is hosted on one server and the the .bat file is hosted on a 2nd server. The two machines serve very different purposes so combining them is not viable.

I have seen fopen, exec, and a couple other PHP methods but I am either not implementing them correctly or they are not the correct approach to use in the first place.

Say that the server with the .bat file is at IP address 200.100.100.1
Say my website is hosted at 100.100.200.2

The .bat file I am trying to execute (for example) would be something like this:

@ECHO OFF
echo Hello, World.
pause

I have searched around quite a bit and have either not been asking my question correctly, or perhaps this is not possible to do at all (I have a hard time believing no one has asked this question before).

Thank you to all in advance.

brockmvendors
  • 23
  • 1
  • 6
  • You might be looking for [**this**](https://stackoverflow.com/a/835955/2518525). Apart from that, the way I see it being run would be Server #1 contacting a PHP script on Server #2 (*via API or similar, with password protection*) that then runs the call like you'll find in the above link. – Darren Jun 08 '18 at 01:39
  • what error do you get from `exec` ? Have you tried using the full path to the batch ? – hexYeah Jun 08 '18 at 02:16

0 Answers0