Solved

Call BAT file from PHP on IIS 6.0 server

Posted on 2011-09-07
6
290 Views
Last Modified: 2012-06-21
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

0
Comment
Question by:Scamquist
  • 3
  • 3
6 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 36498905
You will have to go into IIS Admin, locate that file 'bat' file in the website, right click on it, select properties, and give Execute permissions since 'bat' files are considered 'executable' files.  Default permissions are 'read only' on files in IIS unless you change them.
0
 
LVL 1

Author Comment

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

 IIS Image
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36499348
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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:Scamquist
ID: 36499389
Checked "Script source access"

Opened the page.  Clicked Do IT!

no error.  Just displayed DONE!
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36499457
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.
0
 
LVL 1

Author Closing Comment

by:Scamquist
ID: 36510409
Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now