Taking Advantage of DOSKEY
Windows 7 loads the DOSKEY
utility by default when you start any command-line session. This useful
little program brings a number of advantages to your command-line work:
You can recall previously entered commands with just a keystroke or two.
You can enter multiple commands on a single line.
You can edit commands instead of retyping them.
The next few sections take you through the specifics.
Recalling Command Lines
The simplest DOSKEY feature is command recall. DOSKEY maintains a command history buffer
that keeps a list of the commands you enter. To scroll through your
previously entered commands in reverse order, press the up-arrow key;
when you’ve done that at least once, you can change direction and run
through the commands in the order you entered them by pressing the
down-arrow key. To rerun a command, use the arrow keys to find it and
then press Enter.
If you don’t want to enter commands from the history buffer, press Esc to get a clean command line.
Table 2 lists all the command-recall keys you can use.
Table 2. DOSKEY Command-Recall Keys
|Up arrow||Recall the previous command in the buffer.|
|Down arrow||Recall the newest command in the buffer.|
|Page Up||Recall the oldest command in the buffer.|
|Page Down||Recall the newest command in the buffer.|
|F7||Display the entire command buffer.|
|Alt+F7||Delete all commands from the buffer.|
|F8||Have DOSKEY recall a command that begins with the letter or letters you’ve typed on the command line.|
prompt you for a command list number. (You can see the numbers with the
F7 key.) Type the number and press Enter to recall the command.|
The command history buffer holds 50 commands by default. If you need a larger buffer, run DOSKEY with the /LISTSIZE=buffers
switch, where buffers is the number of commands you want to store. You also need to include the /REINSTALL switch to install a new copy of DOSKEY,
which puts the new history buffer setting into effect. For example, to
change the buffer size to 100, enter the following command:
doskey /listize=100 /reinstall
Entering Multiple Commands on a Single Line
DOSKEY enables you to run multiple commands on a single line. To do this, insert the characters &&
between commands. For example, a common task is to change to a
different drive and then run a directory listing. Normally, you’d do
this with two separate commands:
With DOSKEY, however, you can do it on one line, like so:
can enter as many commands as you like on a single line, but just
remember that the total length of the line can’t be more than 8,191
characters (which should be plenty!).
Editing Command Lines
of simply rerunning a previously typed command, you might need to run
the command again with slightly different switches or parameters.
Rather than retyping the whole thing, DOSKEY
enables you to edit any recalled command line. You use various keys to
move the cursor to the offending letters and replace them. Table 3 summarizes DOSKEY’s command-line editing keys.
Table 3. DOSKEY Command-Line Editing Keys
|Left arrow||Move the cursor one character to the left.|
|Right arrow||Move the cursor one character to the right.|
|Ctrl+left arrow||Move the cursor one word to the left.|
|Ctrl+right arrow||Move the cursor one word to the right.|
|Home||Move the cursor to the beginning of the line.|
|End||Move the cursor to the end of the line.|
|Delete||Delete the character over the cursor.|
|Backspace||Delete the character to the left of the cursor.|
|Ctrl+Home||Delete from the cursor to the beginning of the line.|
|Ctrl+End||Delete from the cursor to the end of the line.|
between Insert mode (your typing is inserted between existing letters
on the command line) and Overstrike mode (your typing replaces existing
letters on the command line).|