Link to home
Start Free TrialLog in
Avatar of Scamquist
ScamquistFlag for United States of America

asked on

Call BAT file from PHP on IIS 6.0 server

I am trying to call a bat file from php.  I am testing this so the contents of the bat file is:
Msg * "If this opened, the call worked"

All it is intended to do is open a message box with some text.

This attached code just shows DONE! on the screen when I clock the Do It button.  The message box does not open.

The full path to the bat file is:
C:\Inetpub\wwwroot\PHP_Call.bat

The full path to the php file is:
C:\Inetpub\wwwroot\CallFile.php

Any ideas?
<?php
if(isset($_POST['submit']))
{
exec("PHP_Call.bat");
echo "Done!";
} else {
// display the form
?>
<form action="" method="post">
<input type="submit" name="submit" value="DO IT!">
</form>
<?php
}
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Scamquist

ASKER

I can't seem to find where to permit the bat file as an executable.
Am I looking in the wrong place?

 User generated image
Click on "Script source access" then.  I was expecting something else.  I tried it and I got this:


Warning: exec() [function.exec]: Unable to fork [PHP_Call.bat] in C:\Inetpub\wwwroot\EXECBAT.PHP on line 13
Checked "Script source access"

Opened the page.  Clicked Do IT!

no error.  Just displayed DONE!
Then it's probably working.  The message would displayed on the command line since it's a command line batch file.  But you're not on the command line, you're in your browser so you woudln't see it.
Thank you.