DOSKEY Utility in MS-DOS 6.22 Explained
The DOSKEY utility in MS-DOS 6.22 is a terminate-and-stay-resident (TSR) program that significantly improves the usability of the command-line interface. When loaded into memory, DOSKEY introduces three primary capabilities: command history tracking and recall, enhanced in-line command editing, and the creation of custom command-line macros. By eliminating the need to retype long or repetitive commands, DOSKEY acts as a major productivity tool for navigating and administering the operating system.
Command History and Recall
Without DOSKEY, MS-DOS only allows you to recall the single most
recently typed command using the F3 key. Once DOSKEY is
executed, it allocates a dedicated memory buffer to store a running
history of executed commands.
- Up and Down Arrows: Step backward and forward through the history of entered commands.
- Page Up and Page Down: Jump immediately to the oldest or newest command in the current buffer.
- F7 Key: Displays a numbered list of all commands currently stored in the history buffer.
- F8 Key: Searches the history for commands starting with characters you have already typed at the prompt.
- F9 Key: Prompts for a specific line number from the
F7list and instantly places that command at the prompt. - Alt + F7: Clears the entire command history buffer from memory.
Enhanced Command-Line Editing
DOSKEY extends standard MS-DOS text manipulation directly at the prompt:
- Left and Right Arrow Keys: Move the cursor back and forth across the current command string without erasing characters.
- Home and End Keys: Instantly move the cursor to the beginning or end of the command line.
- Insert Key: Toggles between insert mode (adding characters between existing text) and overwrite mode (typing over existing text).
- Ctrl + Left / Right Arrow: Jump the cursor one full word to the left or right.
- Esc Key: Erases the entire current line without executing it.
Command Macros
DOSKEY allows users to define custom shorthand commands, known as
macros, which execute directly from memory. Unlike .BAT
(batch) files, macros run faster because they do not require disk
access.
To create a macro, the basic syntax is:
DOSKEY macroname=command
DOSKEY uses specific parameter codes within macro definitions:
- $1 through $9: Represent command-line arguments passed to the macro.
- $*: Captures all parameters typed after the macro name.
- $T: Acts as a command separator, allowing multiple commands to execute in sequence on a single line.
- $G and $L: Represent the output (
>) and input (<) redirection operators.
For example, typing DOSKEY ls=dir /w /p creates a macro
called ls that displays directory contents across the
screen in wide format, pausing between pages.
Memory Usage and Execution
When executed, DOSKEY occupies approximately 3 to 4 KB of RAM.
Because MS-DOS 6.22 relies heavily on conventional memory (the first 640
KB of RAM), DOSKEY is typically loaded into upper memory via the
AUTOEXEC.BAT file using the command:
LH DOSKEY (or LOADHIGH DOSKEY)
This configuration grants full access to the utility's editing, history, and macro features during every DOS session without sacrificing vital conventional memory required by DOS-based applications and games.