HOWTO: Run DOS Batch Files Using Internet Information Server 4

ID: Q199828


The information in this article applies to:


SUMMARY

DOS batch files are run by default under Microsoft's Internet Information Server 3 (IIS3). But under Internet Information Server 4 (IIS4), 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:

  1. Run the IIS4 Management Console application.


  2. Edit the properties for your web site (right-click your web site in the tree display and select Properties).


  3. Select the Home Directory tab.


  4. In the Application Settings box select Configuration.


  5. On the App Mappings tab click Add.


  6. 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).


  7. Make sure that the Script Engine and Check that files exists check boxes are selected.


  8. Save by clicking OK, Apply, OK, and OK.


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 < and > 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.

© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Scott R. deBeaubien, Microsoft Corporation

Additional query words: kbDSupport


Keywords          : kbInternet 
Version           : winnt:4.0
Platform          : winnt 
Issue type        : kbhowto 

Last Reviewed: March 27, 1999