Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

That's because a bat file is a queued list of commands for a prompt. Try the following:

cmd /c myfile.bat

(it may be /k too, forget which executes and closes)

Also, duplicate of How do you run a .bat file from PHP?How do you run a .bat file from PHP?

EDIT

<?php
  // http://www.php.net/manual/en/function.exec.php#85930
  
  $_ = null;
  
  // If you care about the return value, use this:
    passthru("C:\\WINDOWS\\system32\\cmd.exe /c custom.bat",$_);
    header('Content-Type: text/plain');
    echo $_;
  // if you don't care, just use this:
    $_ = exec("C:\\WINDOWS\\system32\\cmd.exe /c custom.bat");
?>

That's because a bat file is a queued list of commands for a prompt. Try the following:

cmd /c myfile.bat

(it may be /k too, forget which executes and closes)

Also, duplicate of How do you run a .bat file from PHP?

EDIT

<?php
  // http://www.php.net/manual/en/function.exec.php#85930
  
  $_ = null;
  
  // If you care about the return value, use this:
    passthru("C:\\WINDOWS\\system32\\cmd.exe /c custom.bat",$_);
    header('Content-Type: text/plain');
    echo $_;
  // if you don't care, just use this:
    $_ = exec("C:\\WINDOWS\\system32\\cmd.exe /c custom.bat");
?>

That's because a bat file is a queued list of commands for a prompt. Try the following:

cmd /c myfile.bat

(it may be /k too, forget which executes and closes)

Also, duplicate of How do you run a .bat file from PHP?

EDIT

<?php
  // http://www.php.net/manual/en/function.exec.php#85930
  
  $_ = null;
  
  // If you care about the return value, use this:
    passthru("C:\\WINDOWS\\system32\\cmd.exe /c custom.bat",$_);
    header('Content-Type: text/plain');
    echo $_;
  // if you don't care, just use this:
    $_ = exec("C:\\WINDOWS\\system32\\cmd.exe /c custom.bat");
?>
Added demo because some people can't just google a solution themselves.
Source Link
Brad Christie
  • 101.7k
  • 16
  • 160
  • 200

That's because a bat file is a queued list of commands for a prompt. Try the following:

cmd /c myfile.bat

(it may be /k too, forget which executes and closes)

Also, duplicate of How do you run a .bat file from PHP?

EDIT

<?php
  // http://www.php.net/manual/en/function.exec.php#85930
  
  $_ = null;
  
  // If you care about the return value, use this:
    passthru("C:\\WINDOWS\\system32\\cmd.exe /c custom.bat",$_);
    header('Content-Type: text/plain');
    echo $_;
  // if you don't care, just use this:
    $_ = exec("C:\\WINDOWS\\system32\\cmd.exe /c custom.bat");
?>

That's because a bat file is a queued list of commands for a prompt. Try the following:

cmd /c myfile.bat

(it may be /k too, forget which executes and closes)

Also, duplicate of How do you run a .bat file from PHP?

That's because a bat file is a queued list of commands for a prompt. Try the following:

cmd /c myfile.bat

(it may be /k too, forget which executes and closes)

Also, duplicate of How do you run a .bat file from PHP?

EDIT

<?php
  // http://www.php.net/manual/en/function.exec.php#85930
  
  $_ = null;
  
  // If you care about the return value, use this:
    passthru("C:\\WINDOWS\\system32\\cmd.exe /c custom.bat",$_);
    header('Content-Type: text/plain');
    echo $_;
  // if you don't care, just use this:
    $_ = exec("C:\\WINDOWS\\system32\\cmd.exe /c custom.bat");
?>
Source Link
Brad Christie
  • 101.7k
  • 16
  • 160
  • 200

That's because a bat file is a queued list of commands for a prompt. Try the following:

cmd /c myfile.bat

(it may be /k too, forget which executes and closes)

Also, duplicate of How do you run a .bat file from PHP?