Calls Doskey.exe, which recalls Windows XP commands, edits command lines, and creates macros.
doskey {/reinstall | /listsize=size | /macros:[{all | exename}] | /history | /insert | /overstrike | /exename=exename | /macrofile=FileName | macroname=[text]}
/reinstall : Installs a new copy of Doskey.exe. Clears the command history buffer.
/listsize=size : Specifies the maximum number of commands in the history buffer.
/macros : Displays a list of all doskey macros. You can use a redirection symbol (>) with /macros to redirect the list to a file. You can abbreviate /macros to /m.
all : Displays doskey macros for all executables.
exename : Displays doskey macros for the specified executable.
/history : Displays all commands stored in memory. You can use a redirection symbol (>) with /history to redirect the list to a file. You can abbreviate /history as /h.
{/insert | /overstrike} : Specifies whether new text you type is to replace old text. If you use /insert, new text that you type on a line is inserted into old text (that is, as if you pressed the INSERT key). If you use /overstrike, new text replaces old text. The default setting is /overstrike.
/exename=exename : Specifies the program (that is, executable) in which the doskey macro runs.
/macrofile=FileName : Specifies a file containing macros that you want to install.
macroname=[text] : Creates a macro that carries out the commands specified by text. Macroname specifies the name you want to assign to the macro. Text specifies the commands you want to record. If text is left blank, macroname is cleared of any assigned commands.
/? : Displays help at the command prompt.
| • | Using Doskey.exe Doskey.exe is always available for all character-based, interactive programs (such as program debuggers or file transfer programs), and maintains a command history buffer and macros for each program that it starts. You cannot use doskey command-line options from a program. You must run doskey command-line options before you start a program. Program key assignments override doskey key assignments. | ||||||||||||||||||||||||||||||||||||||
| • | Recalling a command To recall a command, you can use any of the following keys after starting Doskey.exe. If you use Doskey.exe within a program, that program's key assignments take precedence.
| ||||||||||||||||||||||||||||||||||||||
| • | Editing the command line With Doskey.exe, you can edit the current command line. If you use Doskey.exe within a program, that program's key assignments take precedence and some Doskey.exe editing keys might not work. The following table lists doskey editing keys and their functions.
| ||||||||||||||||||||||||||||||||||||||
| • | Using doskey within a program Certain character-based, interactive programs, such as program debuggers or file transfer programs (FTP), automatically use Doskey.exe. To use Doskey.exe, a program must be a console process and use buffered input. Program key assignments override doskey key assignments. For example, if the program uses the F7 key for some function, you cannot get a doskey command history in a pop-up window. With Doskey.exe you can maintain a command history for each program you start, repeat and edit previous commands at the program's prompt, and start doskey macros created for the program. If you exit and then restart a program from the same Command Prompt window, the command history from the previous program session is available. You must run Doskey.exe before you start a program. You cannot use doskey command-line options from a program's command prompt, even if the program has a shell command. If you want to customize how Doskey.exe works with a program and create doskey macros for that program, you can create a batch program that modifies Doskey.exe and starts the program. | ||||||||||||||||||||||||||||||||||||||
| • | 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, after you press ENTER, Doskey.exe returns your keyboard to replace mode. You must press INSERT again to return to insert mode. Use /insert to switch your keyboard to insert mode each time you press ENTER. Your keyboard effectively remains in insert mode until you use /overstrike. You can temporarily return to replace mode by pressing the INSERT key, but after you press ENTER, Doskey.exe returns your keyboard to insert mode. The insertion point changes shape when you use the INSERT key to change from one mode to the other. | ||||||||||||||||||||||||||||||||||||||
| • | Creating a macro You can use Doskey.exe to create macros that carry out one or more commands. The following table lists special characters you can use to control command operations when you define a macro.
| ||||||||||||||||||||||||||||||||||||||
| • | Running a doskey 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 white space to separate parameters. You cannot run a doskey macro from a batch program. | ||||||||||||||||||||||||||||||||||||||
| • | Creating a macro with the same name as a Windows XP command If you always use a particular command with specific command-line options, you can create a macro that has the same name as the command. To specify whether you want to run the macro or the command, follow these guidelines:
| ||||||||||||||||||||||||||||||||||||||
| • | Deleting a macro To delete a macro, type: doskey macroname= |
The /macros and /history command-line options are useful for creating batch programs to save macros and commands. For example, to store all current doskey macros, type:
doskey /macros > macinit
To use the macros stored in Macinit, type:
doskey /macrofile=macinit
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, as follows:
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 in wide display format. You can use $* at the end of the macro to append other command-line options to dir when you run TX.
The following macro uses a batch parameter for a new directory name:
doskey mc=md $1$tcd $1
The macro creates a new directory and then changes to it from the current directory.
To use the preceding macro to create and change to a directory named Books, type:
mc books
To create a doskey macro for a program called Ftp.exe, include /exename as follows:
doskey /exename:ftp.exe go=open 10.127.1.100$tmget *.TXT c:\reports$bye
To use the preceding macro, start ftp. At the ftp prompt, type:
go
Ftp runs the open, mget, and bye commands.
To create a macro that performs a quick and unconditional format of a disk, type:
doskey qf=format $1 /q /u
To format a disk in drive A quickly and unconditionally, type:
qf a:
| Format | Meaning |
Italic | Information that the user must supply |
Bold | Elements that the user must type exactly as shown |
Ellipsis (...) | Parameter that can be repeated several times in a command line |
Between brackets ([]) | Optional items |
Between braces ({}); choices separated by pipe (|). Example: {even|odd} | Set of choices from which the user must choose only one |
Courier font | Code or program output |