DosKey is a TSR designed to assist working from the command line by making it easier to edit the command line, by remembering previous commands, and being able to record macros.


To load Doskey:
DOSKEY [/Switches]

/B:xxxSets the size of the buffer for macros and commands. The minimum value of xxx is 256 and the default is 512 (bytes). If DOSKEY is already running, it must be reloaded (with /R) when changing the buffer size.
/E:On|OffEnables|Disables the display of commands when a macro plays. E(cho) is On by default.
/F:filenameRetrieves filename - a text file containing a list of macros in the form Macroname=Text
/HDisplays all commands stored in memory. (This list will not be redirected to a file).
/I|OSpecifies whether text is entered in Insert or Overstrike mode by default. In either case the alternative mode can be selected by using <Insert> but the default is reset as soon as <Enter> is used. The default mode is Overstrike.
/K:xxSets the size of the keyboard type-ahead buffer. The default is 15 (characters). If DosKey is already running, it must be reloaded (with /R) when changing the buffer size.
/LSets the maximum size of the line edit buffer. The default is 128 (characters).
/MDisplays a list of all DosKey macros currently in the buffer. This list can be redirected to a text file using standard Dos redirection (>)
/RInstalls a new instance of DosKey. If DosKey is already running, the buffer is cleared of both macros and the Command Line history. Note that installing a new instance of DosKey does not remove the previous instance. Thus each use of /R takes another 5K of conventional/upper memory.

To create a Doskey macro:
DOSKEY Macroname=Text

To play a macro:

To delete a macro:
DOSKEY Macroname=

MacronameThe name of the macro. This is a string of one or more characters possibly modified by the Ctrl and/or Alt keys.
TextThe text string to be assigned to Macroname. This will typically be one or more Dos commands along with appropriate parameters and/or switches.

DosKey Commands

Left/Right cursorMoves the cursor back/forward one character.
Ctrl + Left/Right cursorMoves the cursor back/forward one word.
Home/EndMoves the cursor to beginning/end of line.
Up/Down cursorTo scroll up (and back) through the list of stored commands. Each press of the "up" key recalls the previous command and displays it on the command line.
Page Up/DownRecalls the oldest/most recent command in the buffer
F1Copies the next character from the Template to the Command Line
F2 + keyCopies text from the Template up to (but not including) key.
F3Copies the Template from the present character position to the Command Line.
F4 + keyDeletes the characters from the present character position up to (but not including) key.
F5Copies the current command to the Template and clears the Command Line.
F6Places an end-of-file character (^Z) at the current position of the Command Line.
F7Displays a numbered list of the command history.
Alt-F7Deletes all commands stored in the buffer.
Chars + F8Entering one or more characters Chars followed by F8 will display the most recent command beginning with Chars. Pressing F8 again will display the next most recent command beginning with Chars, and so on.
F9 + Command#Displays the designated command on the command line.
Alt-F10Deletes all macro definitions.

Doskey Special Characters

The following special characters can be used in macros to control command operations:

$GRedirects output - equivalent to the redirection symbol >
$G$GAppends output to the end of a file - equivalent to the append symbol >>
$LRedirects input - equivalent to the symbol <
$BSends macro output to a command - equivalent to the pipe symbol |
$TSeparates commands when creating macros or typing commands on the Doskey command line
$$Use for the $ sign
$1 to $9Represents any command-line parameters that can be specified when the macro is run. Comparable with the %1 to %9 characters in batch programs
$*Represents command-line information that can be specified when macroname is written. $* is similar to the replacable parameters $n except that everything typed on the command line after macroname is substituted for the $* in the macro.


  1. See Using DosKey for further information on editing the command line and creating and using macros.
  2. The /E(cho) and /I(nsert)|O(vertype) states can be modified, the /H(istory) and /M(acro) lists displayed, and /F(ile) retrieved even after DosKey is initially loaded by reentering DOSKEY along with the appropriate switch(es). This action does not affect the commands and macros stored in the buffer. However, the /B(ufsize), /L(ine size), and /K(eyboard buffer) cannot be changed without using the /R(einstall) switch which removes all stored commands and macros.
  3. DosKey is a memory resident program that, once loaded, cannot be unloaded. It occupies 4 176 bytes of conventional (or upper, if available) memory, plus the size of the buffer (minimum: 256 bytes; default 512 bytes).

File Details

File NameDefault LocationDos Ver.Win Ver.SizeDateSource
Doskey.comc:\windows\command 7.0Win95 15 43111/07/
7.1Win95 (OSR2.x) 15 495124/08/
Win98 15 495111/05/
Win98 SE 15 495123/04/

Superscripts denote which same size files, if any, are identical (using FC).

If you should have any comments or suggestions,
please contact: Bob Watson
This page last revised:
August 27, 2000.