I am running a dedicated server atm and I have just installed apache 2 and php 4.3.11, I want to be able to run a program on that box via php, is there a simple way to do this?

For example

C:\Test\test.exe

If I wanted to run that would commmand would I use?

Thanks

    Originally posted by bubblenut
    God to the PHP site and do a search for exec. You might be surprised 😉

    never thought of that sigh

      thanks Thorpe and Mike

      <?
      $command="C:\Program Files\Internet Explorer\IEXPLORE.EXE";
      exec($command);
      echo "$command has been executed";
      ?>
      

      I tried this code but it does not work, am I using the exec() incorrectly?

        is that a valid path? sure doesn't look like one.

          weird

          <?
          $command="C:\Program Files\Internet Explorer\IEXPLORE.EXE";
          exec($command);
          echo "$command has been executed";
          ?>

          the

           tag must have striped the \

            Have a look at [man]escapeshellcmd()[/man] also, one should note that [man]exec[/man] only returns the last line from the output of the command. To get everything use [man]shell_exec[/man] and then echo the output.

              I am not having any joy with this, I have tried loads of different combinations with no luck, is there anything else I might be doing wrong?

                Try

                $cmd = 'dir c:\\\\\\';
                
                echo '<pre>';
                
                echo "\n\nEXEC\n";
                
                exec($cmd, $output);
                print_r($output);
                
                echo "\r\n\r\nBACKTICKS";
                
                echo `$cmd`;
                
                echo '</pre>';

                See if either of those works for you

                  Thanks but it did not work 🙁

                    maybe try using the windows scripting hosts 'shell' object through php's com function...

                    <?php
                    
                      $shell = new COM("wscript.shell");
                      $shell->run("test.exe", 3, true);
                    
                    ?>
                    

                      Neither worked... would any setting in the php.ini effect this?

                        Who's your server host? They might be disallowing the exec commands.

                          Set [man]error_reporting[/man] E_ALL and then post up the errors.

                            although that is when I add echo to it otherwise it says nothing

                              What did you echo? Paste your entire script in here please.

                              Also paste the type of operating system your host is running. If you are unsure, make a script that contains nothing but "phpinfo();" and paste the top section in here for us (or paste a link).