Home
> Commands A-M
> Commands Da-Dr
DOSKEY
Description
| Syntax
| Parameters
| Switches
| Related
| Notes
| Examples
| Errorlevels
| Availability
Loads the Doskey program into memory. The Doskey program recalls
operating system commands and enables you to edit command-lines and
create and run macros.
Doskey is a memory-resident program. When installed, Doskey
occupies about 3 kilobytes of resident memory.
Syntax
DOSKEY
/?
DOSKEY [/REINSTALL]
[/BUFSIZE=nnn]
[/E[CHO]:[ON|OFF]]
[/EXENAME=exename]
[/F[ILE]:file
| /MACROFILE:file]
[/K[EYSIZE]:nn]
[/L[INE]:nnn]
[/LISTSIZE=size]
[/M[ACROS][=exename|=ALL]]
[/H[ISTORY]]
[/INSERT
| /OVERSTRIKE]
[macroname=[text]]
[/APPEDIT]
[/COMMAND]
[/PERMANENT]
[/SCRSIZE]
[/XHISTORY]
To start the Doskey program and use the default settings:
DOSKEY
Parameters
- macroname=[text]
(v5.0
Win95
NT3.1)
- Creates a macro that carries out one or more commands
(a Doskey macro). Macroname specifies the name you want to assign
to the macro. Text specifies the commands you want to
record.
Switches
- /?
(NTXP)
- Display help.
- /APPEDIT
(Win95)
- UNDOCUMENTED Enables command-line history in
applications such as DEBUG.EXE.
- /BUFSIZE=nnn
(v5.0
Win95)
- Specifies the size of the buffer in which Doskey stores
commands and Doskey macros. The default size is 512 bytes. The
minimum buffer size is 256 bytes. Beginning with v7.00 BUFSIZE can be
abbreviated as B.
- /COMMAND
(Win95)
- UNDOCUMENTED unknown.
- /E[CHO]:[ON|OFF]
(v7.00
Win95)
- Enables/disables echo of macro expansions. The default is: ON.
- /EXENAME=exename
(NT3.1)
- Specify an executable other than cmd.exe.
- /F[ILE]:file
(v7.00
Win95)
- /MACROFILE:file
(NT3.1)
- Specifies a file containing a list of macros.
- /H[ISTORY]
(v5.0
Win95
NT3.1)
- Displays a list of all commands stored in memory. You can use
a redirection symbol (>) with the /HISTORY switch to redirect
the list to a file.
- /INSERT |
( /OVERSTRIKE
v5.0
NT3.1)
- /I[NSERT] | /O[VERSTRIKE]
(v7.00
Win95)
- Specifies whether new text you type is to replace old text.
If you use the /INSERT switch, new text that you type on a line
is inserted into old text (as if you had pressed the INSERT key).
If you use the /OVERSTRIKE switch, new text replaces old text.
The default setting is: /OVERSTRIKE.
- /K[EYSIZE]:nn
(v7.00
Win95)
- Specifies the size of the keyboard type-ahead buffer. The
default size is 15 bytes.
- /L[INE]:nnn
(v7.00
Win95)
- Sets maximum size of the line edit buffer. The default size
is 128 bytes.
- /LISTSIZE=size
(NT3.1)
- Limit the number of commands remembered by the buffer.
- /M[ACROS]
(v5.0
Win95
NT3.1)
- Displays a list of all Doskey macros. You can use a
redirection symbol (>) with the /MACROS switch to redirect the
list to a file.
- /MACROS:ALL
(NT3.1)
- Display all Doskey macros for all executables.
- /MACROS:exename
(NT3.1)
- Display all Doskey macros for the given executable.
- /PERMANENT
(Win95)
- UNDOCUMENTED unknown.
- /REINSTALL
(v5.0
NT3.1)
- /R[EINSTALL]
(v7.00
Win95)
- Installs a new copy of the Doskey program, even if one is
already installed. In the latter case, the /REINSTALL switch also
clears the buffer.
- /SCRSIZE
(Win95)
- UNDOCUMENTED unknown.
- /XHISTORY
(Win95)
- UNDOCUMENTED unknown.
Related
Equivalent Linux BASH commands:
m4 - Macro processor.
history - Command history.
Notes
Recalling a command
To recall a command, you can use any of the keys after
loading DOSKEY into memory:
- UP ARROW
- Recalls the operating system command you used before the one displayed.
- DOWN ARROW
- Recalls the operating system command you used after the one displayed.
- PAGE UP
- Recalls the oldest operating system command you used in the current session.
- PAGE DOWN
- Recalls the most recent operating system command you used.
Editing the command-line
With the Doskey program, you can edit the current command-line.
The list describes the Doskey editing keys and their
functions:
- LEFT ARROW
- Moves the cursor back one character.
- RIGHT ARROW
- Moves the cursor forward one character.
- CTRL+LEFT ARROW
- Moves the cursor back one word.
- CTRL+RIGHT ARROW
- Moves the cursor forward one word.
- HOME
- Moves the cursor to the beginning of the line.
- END
- Moves the cursor to the end of the line.
- ESC
- Clears the command from the display.
- F1
- Copies one character from the template to the operating
system command-line. (The template is a memory buffer that
holds the last command you typed.)
- F2
- Searches forward in the template for the next key you type
after pressing F2. Doskey inserts the text from the template up
to but not including the character you specify.
- F3
- Copies the remainder of the template to the command-line.
Doskey begins copying characters from the position in the
template that corresponds to the position indicated by the cursor
on the command-line.
- F4
- Deletes characters, beginning with the current character
position, up to a character you specify. To use this editing key,
press F4 and type a character. Doskey deletes up to, but not
including, that character.
- F5
- Copies the current command into the template and clears the
command-line.
- F6
- Places an end-of-file character (CTRL+Z) at the current
position on the command-line.
- F7
- Displays all commands stored in memory, with their associated
numbers. Doskey assigns these numbers sequentially, beginning
with 1 for the first (oldest) command stored in memory.
- ALT+F7
- Deletes (clears) all commands stored in memory.
- F8
- Searches memory for a command that you want Doskey to
display. To use this editing key, type the first character, or
the first few characters, of the command you want Doskey to
search for and then press F8. Doskey displays the most recent
command that begins with the text you typed. Press F8 repeatedly
to cycle through all the commands that start with the characters
you specified.
- F9
- Prompts you for a command number and displays the command
associated with the number you specify. To display all the
numbers and their associated commands, press
F7.
- ALT+F10
- Deletes (clears) all macro definitions.
Specifying a default insert mode
If you press the INSERT key, you can type text on the Doskey
command-line in the middle of old text without replacing the old
text. However, once you press ENTER, Doskey returns your keyboard
to replace mode. You must press INSERT again to return to insert
mode.
The /INSERT switch puts
your keyboard in insert mode each time you press ENTER. Your
keyboard effectively remains in insert mode until you use the
/OVERSTRIKE switch. You
can temporarily return to replace mode by pressing the INSERT key;
but once you press ENTER, Doskey returns your keyboard to insert
mode.
The cursor changes shape when you use the INSERT key to change
from one mode to the other.
Creating a macro
You can use the Doskey program to create macros that carry out
one or more operating system commands.
You can use special characters to control command
operations when defining a macro:
- $G or $g
- Redirects output. Use either of these special characters to
send output to a device or a file instead of to the screen. This
character is equivalent to the redirection symbol for output
(>).
- $G$G or $g$g
- Appends output to the end of a file. Use either of these
special double characters to append output to an existing file
rather than replace the data in the file. These double characters
are equivalent to the "append" redirection symbol for output
(>>).
- $L or $l
- Redirects input. Use either of these special characters to
read input from a device or a file instead of from the keyboard.
This character is equivalent to the redirection symbol for input
(<).
- $B or $b
- Sends macro output to a command. Using one of these special
characters is equivalent to using the pipe (|) on a command
line.
- $T or $t
- Separates commands. Use either of these special characters to
separate commands when you are creating macros or typing commands
on the Doskey command-line.
- $$
- Specifies the dollar-sign character ($).
- $1 through $9
- Represents any command-line information you want to specify
when you run the macro. The special characters $1 through $9 are
batch parameters, which make it possible for you to use different
data on the command-line each time you run the macro. The $1
character in a DOSKEY command is similar to the %1 character in a
batch program.
- $*
- Represents all the command-line information you want to
specify when you type the macro name. The special character $* is
a replaceable parameter that is similar to the batch parameters
$1 through $9, with one important difference. Here, everything
you type on the command-line after the macro name is substituted
for the $* in the macro.
For example, to create a macro that performs a quick and
unconditional format of a disk, type:
DOSKEY qf=format $1 /q /u
For information about quick and unconditional formatting, see
the FORMAT command.
You can use the DOSKEY command in a batch program to create a
macro.
Running a macro
To run a macro, type the macro name starting at the first
position on the command-line. If the macro was defined with $* or
any of the batch parameters $1 through $9, use a space to separate
parameters.
You could run the QF macro created in the previous example to
format a disk in drive A quickly and unconditionally. To do so, you
would type:
qf a:
You cannot run a macro from a batch program.
Creating a macro with the same name as an DOS command
You might want to create a macro that has the same name as an
operating system command. This can be useful, for example, if you
always use a certain command with specific switches. To specify
whether you want to run the macro or the operating system command,
The guidelines:
- To run the macro, begin typing the macro name immediately
after the command prompt, with no space between the prompt and
the command name.
- To carry out the command, insert one or more spaces between
the command prompt and the command name.
Deleting a macro
To delete a macro, type:
DOSKEY macroname=
Examples
The /MACROS and
/HISTORY switches are useful
for creating batch programs to save macros and commands. For example,
to create a batch program named MACINIT.BAT that includes all
Doskey macros, type:
DOSKEY /MACROS > macinit.bat
To use the MACINIT.BAT file, edit it to include the DOSKEY
command at the beginning of each macro line.
To create a batch program named TMP.BAT that contains recently
used commands, type:
DOSKEY /HISTORY > tmp.bat
To define a macro with multiple commands, use $T to separate
commands:
DOSKEY tx=cd\temp$tdir/w $*
In the preceding example, the TX macro changes the current
directory to TEMP and then displays a directory listing, using the
wide display format. You can use $* at the end of the macro to
append other switches to the DIR command
when you run TX.
This macro uses a batch parameter for a new directory
name. The macro first creates a new directory and then changes to
it from the current directory.
DOSKEY mc=md $1$tcd $1
To use the preceding macro to create and change to a directory
named BOOKS, type:
mc books
To create a macro that uses batch parameters for moving a file
or group of files, type:
DOSKEY mv=copy $1 $2 $t del $1
To create a macro that causes the MEM
command to pause after each screen, type:
DOSKEY mem=mem $* /p
Errorlevels
none.
Availability
- External
-
- DOS
-
v5.0
v5.0A
v5.00.02
v5.001A
v5.01
v5.02
v6.0
v6.10
v6.2
v6.21
v6.22
v6.23
v7.00
v7.0R1
v7.10
v8.00
- Windows
-
Win95
Win98
WinME
- Windows NT
-
NT3.1
NT3.5
NT3.51
NT4
NT2000
NTXP
NT2003
Last Updated: 2006/12/01
Direct corrections or suggestions to:
Rick Lively