Doskey - DOS/Command Prompt Reference
Extends the input methods for the prompt.
[MS-DOS, Windows 95/98/Me] doskey is ‘doskey.com’ application.
[Windows NT series] doskey is ‘doskey.exe’ application.
Syntax
doskey [/BUFSIZE:<size>] [/ECHO:on|off] [/EXENAME=<exe-file>] [/FILE:<file>] [/HISTORY] [/INSERT | /OVERSTRIKE] [/KEYSIZE:<size>] [/LINE:<size>] [/LISTSIZE=<size>] [/MACROS[:ALL | :<exe-file>]] [/MACROFILE=<file>] [/REINSTALL] [<macro-name>=<value>]
* While ‘:’ can sometimes be substituted with ‘=’, the reverse is not true; ‘=’ cannot be substituted with ‘:’.
Options
/BUFSIZE:<size> | [MS-DOS, Windows 95/98/Me] Sets the buffer size for storing macros and command history. (No impact on performance?) The /REINSTALL option is required for configuration. /BUFSIZE can be abbreviated as /B. |
/ECHO:on|off | [Windows 95/98/Me] Specifies whether to display the actual command being executed during macro execution. It's similar to the sense of the echo command (echo on/echo off). |
/EXENAME=<exe-file> |
[Windows NT series] Specify the executable file as <exe-file>. When configuring a macro with this specification, the set macro can only be used for command input in that executable file. By specifying /EXENAME with /MACROS or by using /MACROS:<exe-file>, you can display a list of macros available for use in <exe-file>. |
/FILE:<file>, /MACROFILE=<file> | Reads the file defining the macros. /FILE is available for Windows 95/98/Me, while /MACROFILE is used for Windows NT series. |
/HISTORY | Displays the command history maintained by Doskey. |
/INSERT | /OVERSTRIKE |
Specifying /INSERT puts the command input in insert mode (default for Windows NT series). Specifying /OVERSTRIKE puts the command input in overwrite mode (default for MS-DOS and Windows 9x). [Windows 95/98/Me] /INSERT can be abbreviated as /I, and /OVERSTRIKE can be abbreviated as /O. |
/KEYSIZE:<size> | [Windows 95/98/Me] Specifies the size of the keyboard buffer (default is 15; details are unclear). The /REINSTALL option is required for configuration. /KEYSIZE can be abbreviated as /K. |
/LINE:<size> | [Windows 95/98/Me] Specifies the size of the line-editing buffer. This value represents the maximum number of bytes that can be entered in a single command line (default is 128). The /REINSTALL option is required for configuration. /LINE can be abbreviated as /L. |
/LISTSIZE=<size> | [Windows NT series] Specifies the number of command input history entries to retain (default is 50). Setting a value smaller than before will result in the deletion of overflowed history. |
/MACROS |
Displays a list of currently defined macros. [Windows NT series] If macros are set for each executable file, they will not be displayed in the list. |
/MACROS:ALL | [Windows NT series] Displays all macros, including those set for each executable file. |
/MACROS:<exe-file> | [Windows NT series] Display macros set for the executable file <exe-file>. This has the same effect as calling /MACROS with /EXENAME specified. |
/REINSTALL |
Reloads Doskey. At this time, the command history will be cleared. For MS-DOS, Windows 95/98/Me, the macros set will also be cleared, but for Windows NT series, macros will not be cleared. [Windows 95/98/Me] /REINSTALL can be abbreviated as /R. |
<macro-name>=[<value>] |
Define <macro-name> as <value> as a macro (alias). This allows you to achieve the same effect as <value> by entering <macro-name>. <value> can include spaces and ‘/’ characters, so this option must always be placed at the end. If <value> is omitted (when entering <macro-name> and ‘=’ only), it deletes the macro specified by <macro-name>. |
Details
About Doskey
Doskey adds useful features to the prompt. For example, if you run ‘doskey’ without specifying any arguments, the commands you enter thereafter are saved, and you can reference and re-run them using the up and down arrow keys.
In the Windows NT series Command Prompt, Doskey is already loaded, so there is no need to run Doskey every time you open the prompt.
In the insert mode configured with /INSERT for Doskey, you can move the cursor with the ←→ keys and insert characters at that position. In overwrite mode with /OVERSTRIKE, characters are overwritten from the cursor position. Pressing the Insert key allows you to switch modes without specifying a switch, but in that case, it reverts to the original after entering a command once.
The macro definition files specified by /FILE or /MACROFILE are text files where contents like "a=b" are written line by line. To output the currently defined macros with Doskey, please refer to the following Samples.
Special characters available in macros
When defining macros with Doskey, you can use the following characters (case-insensitive):
Characters | Meaning |
---|---|
$T |
A command separator. You can use this character as a delimiter to assign multiple commands. (Example: echo A$Techo B ) |
$1 to $9 |
Macro parameters. Using ‘$’ and the numbers 1 through 9 ($1, $2, ..., $9), they get replaced with the additional parameters specified when using the macro (the first parameter goes into $1). |
$* |
Expands to all the arguments of the macro. |
$G |
An output redirection. It is used when you want to write the output of a command to a file or device. |
$G$G |
An append redirection. It is used when you want to append the output of a command to a file or device. |
$L |
An input redirection. It is used when you want a command to receive input from a file or device. |
$B |
A pipe. It is used when you want the output of one command to serve as the input for another command. |
Shortcuts available with Doskey
When Doskey is loaded, the following shortcuts become available. ([Windows NT series] These commands are available initially.)
Key | Action |
---|---|
↑↓ | References the command input history. When referenced, the command is already in the input state. |
Esc | Clears the currently input command. (* If Doskey is not built-in, pressing Esc may not clear the input string.) |
F7 | Displays the history of commands entered so far. |
F8 | References the command input history. If something is entered before pressing F8, only those that match the entered content and the first character will be referenced (prefix match). (Example: If you are entering ‘di’, you can reference commands like ‘dir /w’ and ‘dir /a:d’, but ‘del *.*’ will not be referenced.) |
F9 | You can select a command from the history displayed with F7 by using numbers. Pressing F9 prompts for numeric input, so press the corresponding number key. |
Alt+F7 | Clears the command history. |
Alt+F10 | Clears all defined macros. |
Samples
Sample 1
doskey /insert
Loads Doskey in insert mode into the current prompt. (If specified during DOS startup, it will affect all prompts.)
Sample 2
doskey delall=del *.*
Defines a macro named "delall." From this point on, entering ‘delall’ at the prompt will execute ‘del *.*’.
Sample 3
doskey /macros > macros.txt
Saves the currently defined macros to ‘macros.txt’. Use the following examples to load it.
Sample 4
doskey /file:macros.txt
[Windows 95/98/Me] Reads macros from ‘macros.txt’.
Sample 5
doskey /macrofile=macros.txt
[Windows NT series] Reads macros from ‘macros.txt’.
Sample 6
doskey /exename=ftp.exe mylogin=open ftp.myserver.net
[Windows NT series] Enable the use of a macro named "mylogin" for the command-line FTP tool ‘ftp.exe’ (included with Windows by default). From this point on, entering ‘mylogin’ in ftp.exe will execute ‘open ftp.myserver.net’, establishing a connection to ftp.myserver.net.