Solved

Call BAT file from PHP on IIS 6.0 server

Posted on 2011-09-07
6
287 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 82

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 82

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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 82

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
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 is …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

706 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

17 Experts available now in Live!

Get 1:1 Help Now