I want to run an executable from a web server. This execuatble is on a remote system that fires off another process. Is there anyway to do this with PHP.

Why would I want to do that??
Because it has been requested and currently it is the on ly solution.

A form is submitted and the text is then sent to a bat file as an arg and thenruns a WinBatch.exe and then completes the process.

Any ideas???

    As our senior members are fond of saying "5 minutes with the manual will save you 2 hours on the forums." Lookup the function system(). If you have suffecient permissions you can just use system("winbatch.exe $argstring");.

      Thanks,
      I was thinking system() but was actually trying popen(),

      Now system sounds more logical.

      Thanks

        5 years later

        I'm having a similar problem. I'm trying to run a WinBatch script from a php program.

        I tried system("winbatch.exe $argstring"); but it just echos the code from my script instead of executing it. Does anyone have any idea why?

        Thanks,

        Patricia

          Here's the function. $filewritten is the name of a file that the WinBatch script creates, containing the date and time it last executed successfully. $program is the name of the WinBatch script to be executed. $time2pass is the amount of time to delay before running the WinBatch script again.

          function time2update($filewritten, $program, $time2pass){
          $Diff = 0;
          $program = "WinBatchScripts/".$program;
          // if it has been Diff minutes since the cleaned file was updated, it's time to update it again
          $Diff = intval((time() - filemtime("$filewritten"))/60); //(divide by number sec/min) number of minutes since file updated without errors;
          if (!file_exists($filewritten)){echo "\n\r $filewritten does not exist.\n\r";}
          else {echo "\n\r It has been $Diff minutes since $filewritten was updated.\n\r";}
          if ($Diff > $time2pass OR !file_exists($filewritten))
          {
          echo "\n\r Time to update $program!\n\r";
          system('\php5\php.exe ' . $program);
          }
          else {echo "\n\r Only $Diff minutes have passed. The file does not need to be updated yet. \n\r";};
          }

            6 days later

            Wait, I'm confused. These "WinBatch" scripts are actually PHP scripts?

            If not, why are you executing them with the PHP parser?

              Write a Reply...