How to Create Interactive Menus in MS-DOS 6.22

In MS-DOS 6.22, the primary built-in utility used to build interactive menus inside standard command-line sessions is CHOICE.EXE. This article explains how CHOICE.EXE functions within batch scripts to capture keystrokes and branch execution, outlines the native CONFIG.SYS Multi-Config menu system used during startup, and touches on QBASIC.EXE for advanced text-based user interfaces.

Creating Batch File Menus Using CHOICE.EXE

Introduced natively in MS-DOS 6.0 and present in version 6.22, CHOICE.EXE allows batch files to prompt users for single-character input, pause script execution, and return an exit code (ERRORLEVEL) based on the key pressed.

Prior to CHOICE.EXE, creating interactive menus required third-party utilities or complex workarounds involving PAUSE and file redirection. With CHOICE, a script displays a list of options using standard ECHO commands and evaluates the user's choice using conditional statements.

Example Batch Menu:

@ECHO OFF
CLS
ECHO ===================================
ECHO         DOS 6.22 MAIN MENU
ECHO ===================================
ECHO 1. Launch File Manager
ECHO 2. Run Disk Defragmenter (DEFRAG)
ECHO 3. Exit to Command Prompt
ECHO ===================================
CHOICE /C:123 /N Please select an option (1, 2, or 3): 

IF ERRORLEVEL 3 GOTO EXIT
IF ERRORLEVEL 2 GOTO DEFRAG
IF ERRORLEVEL 1 GOTO MANAGER

:MANAGER
CALL C:\DOS\DOSSHELL.COM
GOTO END

:DEFRAG
DEFRAG
GOTO END

:EXIT
ECHO Exiting to prompt...

:END

Key flags for CHOICE.EXE include:

  • /C:keys: Specifies the allowable keys (e.g., /C:123). If omitted, the default is [Y,N].
  • /N: Suppresses the display of the allowable keys list at the end of the prompt string.
  • /S: Enables case sensitivity.
  • /T:c,nn: Enforces a timeout, defaulting to choice c after nn seconds.

In MS-DOS batch processing, IF ERRORLEVEL conditions must be checked in descending numerical order because the statement evaluates whether the exit code is greater than or equal to the specified number.

Startup Terminal Menus: CONFIG.SYS Multi-Config

While CHOICE.EXE manages menus during an active MS-DOS session, MS-DOS 6.22 also includes a built-in startup menu system managed directly by CONFIG.SYS. This feature, known as Multi-Config, uses internal commands rather than an external .EXE utility:

  • [MENU]: Designates the menu definition header block.
  • MENUITEM=block_name, Display Text: Defines selectable configuration options.
  • MENUDEFAULT=block_name, timeout_seconds: Sets the default option and optional countdown timer.
  • SUBMENU=block_name, Display Text: Enables nested menu layers.

When the system boots, the MS-DOS kernel renders these options as a formatted, arrow-key-navigable text menu directly inside the terminal prior to processing AUTOEXEC.BAT.

Advanced Menus with QBASIC.EXE

For scenarios requiring full-screen borders, custom colors, mouse support, or text input fields, users and system administrators utilized QBASIC.EXE, which shipped standard with MS-DOS 6.22. By combining basic statements like SCREEN 0, LOCATE, COLOR, and INKEY$, developers created complete Text User Interfaces (TUIs) that far exceeded the formatting capabilities of native batch scripting.