Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Call BAT file from PHP on IIS 6.0 server

Posted on 2011-09-07
6
Medium Priority
?
301 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 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 84

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 84

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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

597 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