Solved

Call BAT file from PHP on IIS 6.0 server

Posted on 2011-09-07
6
296 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 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

691 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