6. Tracking Command Line Actions with the DosKey Utility
The DosKey utility
performs three tasks. First, it provides the history feature that most
people use to scroll through existing command line entries. Press Down
Arrow to see the next command, Up Arrow to see the previous command,
Page Down to see the most recent command, and Page Up to see the oldest
command in the history.
Second, you can use this command to edit previous commands. The following list describes the editing features.
LEFT ARROW
Moves to the previous character in the command.
RIGHT ARROW
Moves to the next character in the command.
CTRL+LEFT ARROW
Moves to the previous word in the command.
CTRL+RIGHT ARROW
Moves to the next word in the command.
HOME
Moves to the beginning of the line.
END
Moves to the end of the line.
ESC
Clears the command from the display.
F1
Copies the next character from the same column in the command that you previously issued.
NOTE
The system places the
previous command in a special area of memory called the template and
lets you work with that command based on the current column position.
For example, if you typed Dir *.BAK as the previous command, executed it, and then typed Dir
at the command line, pressing F1 would type a space. Pressing F1 again
would type the asterisk (*) and so on. Using the same example, pressing
F2 and then the letter A would display Dir *.BA
at the command prompt. Using the combination of the template and
function keys helps you reduce the number of keystrokes you make to type
a command.
F2
Searches forward in the previous command for the next key you type after pressing F2.
F3
Copies the remainder of the previous command to the command line.
F4
Deletes
characters from the current cursor position up to a character you
specify. For example, if the command line currently displays Dir *.BAK and the cursor is blinking under the asterisk (*), pressing F4 and the letter B would change the command prompt to read Dir BAK.
F5
Copies the previous command into the current command line.
F6
Places an
end-of-file character (Ctrl+Z) at the current cursor position. You
typically use this feature when using the console to create a file.
F7
Displays all of the
commands stored in the command history in a dialog box. Select a command
using the Up Arrow and Down Arrow. Press Enter to select the command.
DosKey types the selected command at the command prompt. Press Enter
again to execute the command. You can also note the sequential number in
front of the command and use this number with the F9 key.
ALT+F7
Deletes all commands stored in the current command history buffer.
F8
Displays a single
command from the command history that starts with the characters in the
current command. Press F8 multiple times to cycle through the list of
matching commands.
F9
Prompts you for a
history buffer command number, and then displays the command associated
with the number you specify. Press Enter to run the command. Press F7 to
display a list of commands in the command history buffer, along with
their associated command number.
ALT+F10
Deletes all macro definitions.
Third, you can use
this command to create macros. The macros automate some command line
tasks, similarly to batch files, but far more inconveniently. You can
also use these macros to interact with applications. This utility uses the following syntax:
DOSKEY [/REINSTALL] [/LISTSIZE=size] [/MACROS[:ALL | :exename]]
[/HISTORY] [/INSERT | /OVERSTRIKE] [/EXENAME=exename] [/MACROFILE=filename]
[macroname=[text]]
The following list describes each of the command line arguments.
/REINSTALL
Installs a new
copy of DosKey. Use this feature when your current copy has become
corrupted or simply filled with extraneous data.
/LISTSIZE=size
Determines the number of commands that will fit within the command history buffer. The default setting is 10.
/MACROS
Displays a list of
all of the DosKey macros. The output includes command line macros, as
well as those associated with an application.
/MACROS:ALL
Displays a list
of all the DosKey macros for all executables that have DosKey
compatibility. For example, if you create a DosKey macro for the FTP
utility, this command line switch would display it.
/MACROS:
exenameDisplays a list of all the DosKey macros associated with the specified application.
/HISTORY
Displays a list of all of the commands in the command history buffer.
/INSERT
Places DosKey in insert mode. Any new text you type at the command line appears in addition to the existing text.
/OVERSTRIKE
Places DosKey in overstrike mode. Any new text you type at the command line replaces (overwrites) existing text.
/EXENAME=
exenameSpecifies the
name of an executable to use when creating a macro. The resulting macro
runs within that application. The application must support DosKey to use
this functionality. If you don't specify this command line switch, any
macro you create or install runs at the command line and not as part of
an application.
/MACROFILE=
filenameSpecifies a file containing macros that you want to install.
macroname
Specifies the
name for a macro you create. Typing the macro name, followed by an
equals sign, and pressing Enter deletes a macro from the list.
text
Contains the text of
the macro you want to record. You must include a macro name, followed by
an equals sign, followed by the macro text to use this argument. For
example, you can define a macro named MyDir that displays a directory by
typing DosKey MyDir=Dir *.* /P and pressing Enter. After you create this macro, you can type MyDir at the command prompt, press Enter, and DosKey will execute the MyDir macro.
7. Obtaining Command Line Help with the Help Utility
In most cases, you'll type the name of a utility, followed by the /?
command line switch to learn more about it. However, Microsoft decided
to make things difficult in some cases. For example, some utilities
require that you use the /Help command
line switch instead or you might have to use the Help utility to learn
more about the command or utility in question. To see a list of commands
and utilities that Help supports, type Help and press Enter. This utility uses the following syntax:
HELP [command]
The following describes the command line argument.
command
Specifies the name of the command for which you want to obtain more information. If you type Help
by itself and press Enter, you'll see a list of all of the available
commands. You can then choose a specific command to learn more about
with the Help utility.
8. Working with the System Time Using the Time Command
The Time command displays or sets the system time. This command uses the following syntax:
TIME [/T | time]
The following list describes each of the command line arguments.
/T
Displays the date without prompting for a new time. This command line switch only works when you enable command extensions.
time
Specifies the new system time.
9. Changing the Command Window Title with the Title Command
The title that a command
window displays might not seem important at first, but it can be
important for two reasons. First, if you have multiple command windows
open, using a descriptive title can make it easier to locate the correct
command window on the Windows Taskbar. Second, it's important to
remember that Windows associates settings changes you make with the
command window title. Changing the title affects how Windows stores the
settings changes you make. The Title command can change the title of a command window. This command uses the following syntax:
TITLE [string]
The following describes the command line argument.
string
Contains the text for the command window.