Posted On 2005-11-1 by FortyPoundHead
Keywords: Command Reference
Tags: Windows Commandline Windows
Views: 1782


Recall and edit commands at the DOS prompt, and create macros. You cannot run a Doskey macro from a batch file.


DOSKEY [options] [macroname=[text]]


macroname : A short name for the macro.

text : The commands you want to recall.

For example to assign the letter d to the dir/w command DOSKEY d=dir/w

options : for working with macros...

/MACROFILE=filename Specify a file of macros to install

/MACROS Display all Doskey macros

/EXENAME=exename Specify an executable other than cmd.exe

/MACROS:exename Display all Doskey macros for the given executable

/MACROS:ALL Display all Doskey macros for all executables ALT+F10 Clear macro definitions

options : for working with the Command Buffer...

/HISTORY : Display all commands stored in memory.

/LISTSIZE=size : Limit number of commands remembered by the buffer.

/REINSTALL : Install a new copy of Doskey (clears the buffer).

In normal use the command line is always in overwrite mode, DOSKEY can be used to change this to Insert, the insert key will always toggle from one to the other.

/INSERT : By default new text you type at the command line will

be inserted in old text

/OVERSTRIKE : By default new text you type at the command line

will overwrite old

In addition to the above, DOSKEY is loaded into memory for every cmd session so you can use the following Keystrokes at the command line:

UP and DOWN ARROWS or F8 will recall commands

F7 : popup command history (enter to accept, ESC to cancel)

F9 : select a command by number

ESC : clear command line

ALT+F7 : clear command history

INSERT : toggle Insert/Overwrite

The size of the command history can be set from Control Panel, Console or from the properties of any cmd shortcut. Clear all history with DOSKEY /REINSTALL.


A macro to open notepad:

DOSKEY note=notepad.exe

A macro to open WordPad

DOSKEY wpad="C:\Program Files\Windows NT\Accessories\wordpad.exe"

More advanced macro definitions:

$T If you put more than one command in a DOSKEY macro, use $T to separate them. Equivalent to & in a batch file.

$1-$9 Parameters, equivalent to %1-%9 in a batch file.

$* This represents ALL the parameters $1-9

A macro to open a file with WordPad:

DOSKEY wpad="C:\Program Files\Windows NT\Accessories\wordpad.exe" $1

Using the above macro:

wpad MyTextfile.txt

About the Author

FortyPoundHead has posted a total of 1974 articles.

Comments On This Post

No comments on this post yet!

Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.

Your IP address is:

Before you can post, you need to prove you are human. If you log in, this test goes away.

Code Links