Microsoft KB Archive/199828

= How To Run DOS Batch Files Using Internet Server Application Programming Interface =

Article ID: 199828

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft Internet Server Application Programming Interface 4.0

-



This article was previously published under Q199828



SUMMARY
DOS batch files are run by default under Microsoft's Internet Information Server 3 (IIS3). But under Internet Server Application Programming Interface (API), several things must be configured in order for batch files to run on the server side.



MORE INFORMATION
Specifically, the configuration steps for IIS4 are as follows:  Run the IIS4 Management Console application. Edit the properties for your web site (right-click your web site in the tree display and select Properties). Select the Home Directory tab. In the Application Settings box select Configuration. On the App Mappings tab click Add. The executable will be the following on a WinNT 4.0 machine (make sure to use correct path to cmd.exe on your WinNT installation):

C:\WINNT\system32\Cmd.exe /c %s %s

Enter ".bat" for the extension (without the quotes). Make sure that the Script Engine and Check that files exists check boxes are selected.</li> Save by clicking OK, Apply, OK, and OK.</li></ol>

Here is a sample of the batch file that sets Content-Type: text/html header, sends a message to the user's browser, and outputs the results of the SET command. You can use this test to verify when batch files are setup correctly on your IIS4 server.

Copy the following to a file called RunMe.bat:

@echo off echo Content-Type: text/html echo. echo. echo Hello, World! echo ^<PRE^> set echo ^</PRE^> exit

Note that send HTML tags are considered to be special characters for the shell, and therefore must be escaped by a carot character (^).

To test a sample batch file place it to the virtual directory on the server with execute persmissions. The URL to invoke it would look like this:

http://MyServer/scripts/RunMe.bat

Many people had batch (command line or DOS) applications that ran under IIS3 and those relied on reading stdin and writing to stdout. Now that your IIS4 server is configured properly, you should be able to run those same applications as you did under IIS3 and have them behave the same.

NOTE: Once IIS is configured to run batch files, configuring virtual directory with write and execute permissions can open a very big security hole. It could be possible to upload and ran batch file with any command.

Additional query words: kbDSupport

Keywords: kbhowto kbhttp kbcgi KB199828

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.