This article was previously published under Q77457
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
The MS-DOS batch language facility does not provide a means for you toprovide input to control program flow. All information input from youmust be entered from the command line.
By using a short program created with the MS-DOS Debug utility, youcan provide information at the time of batch file execution.
NOTE: Although the Debug program works with MS-DOS 6.0 or 6.2, it isnot required. If you are using MS-DOS 6.0 or 6.2, type help choiceat the MS-DOS command prompt for more information.
The Debug program at the end of this article will wait for you toinput a character from the keyboard and set the value of "errorlevel"equal to the ASCII code value of the character entered. For a list ofASCII characters and their associated values, see the ANSI.SYS sectionin your MS-DOS manual.
Most keyboard characters are represented by only one code. However, thefunctions and ALT key combinations send two codes: a zero, followed byanother code. The REPLY.COM program will set "errorlevel" equal to thesecond code passed. For example, the F8 key sends a zero followed bythe value 66. This will be interpreted by REPLY.COM as the character"B," which has an ASCII value of 66.
REPLY.COM can be used within batch files to allow user input to controlthe flow of the program. For example, the following AUTOEXEC.BAT fileallows you to determine whether or not to install a mouse driverduring startup:
@Echo off path=C:\DOS :Ask Echo Install Mouse Driver (y/n)? Reply If errorlevel 121 if not errorlevel 122 goto install If errorlevel 89 if not errorlevel 90 goto install If errorlevel 110 if not errorlevel 111 goto NoMouse If errorlevel 78 if not errorlevel 79 goto NoMouse goto ask :install c:\mouse\mouse :NoMouse cls ver
For more information about using the "errorlevel" environmentvariable, query on the following word in the Microsoft Knowledge Base:
To create REPLY.COM, enter the text listed in the Instruction column.Press ENTER after each instruction. Do not enter the text listed inthe Comment column; it is for your reference.
Instruction Comment ----------- ------- DEBUG Executes MS-DOS DEBUG utility-A 100 Begin assembling instructions at memory location100xxxx:0100 MOV AH,08 Get character input without echoxxxx:0102 INT 21 Perform MS-DOS servicexxxx:0104 CMP AL,0 Compare AL with zeroxxxx:0106 JNZ 010A If lead zero, get second code of characterxxxx:0108 INT 21 Perform MS-DOS servicexxxx:010A MOV AH,4C Terminate process with return codexxxx:010C INT 21 Perform MS-DOS servicexxxx:010E <ENTER>-rcxCX 0000:e-n REPLY.COM-wWriting 000E bytes-q
"Supercharging MS-DOS," pages 97-98, by Van Wolverton, MicrosoftPress, 1989, 1991 (Updated for Version 4).