DOSKEY
(from Disk Operating System Key)
Changes Windows command line or command recall settings and creates macros.
Syntax:
DOSKEY [/REINSTALL] [/LISTSIZE=dim.] [/MACROS[:ALL | :exe_name]] [/HISTORY] [/INSERT | /OVERSTRIKE] [/EXENAME=exe_name] [/MACROFILE=filename] [macro_name=[text]]
Where:
/REINSTALL
- ResetsDOSKEY
, deleting all command history and disabling text overwriting./LISTSIZE=dim.
- Sets the command buffer size, i.e. the maximum number of commands that can be stored for recall./MACROS
- Displays allDOSKEY
macros./MACROS:ALL
- Displays allDOSKEY
macros for all executable files that haveDOSKEY
macros./MACROS:exe_name
- Displays allDOSKEY
macros for the given file./HISTORY
- Displays all command history./INSERT
- Disables text overwriting on the command line, meaning that characters entered in the middle of a string are inserted to existing ones rather than replacing them./OVERSTRIKE
- Enables text overwriting on the command line./EXENAME=exe_name
- Specifies the executable file./MACROFILE=filename
- Specifies the macro file to install.macro_name
- Specifies the name of the macro you want to create.text
- Specifies the commands you want to store in the macro. If not specified, deletes the macro namedmacro_name
.
In the definition of a DOSKEY
macro, you can use the following codes:
$G
- Greater than symbol (>
, for writing to output file, e.g.$G$G
adds a line to the end of the file).$L
- Less than symbol (<
, for reading from input file).$T
- Command separator. Allows multiple commands in a macro.$1-$9
-DOSKEY
arguments, equivalent to%1-%9
in batch programs. See SHIFTSHIFT.$*
- Symbol replaced by whatever follows the macro name on the command line.
Examples:
1. Display all stored commands of the current Command Prompt window:
doskey /history
2. Display all DOSKEY
macros for the C:\siufboasbofbaisrnoofnasr.exe
file:
doskey /macros /exename="C:\siufboasbofbaisrnoofnasr.exe"
3. After installing a macro, you can use it in place of the specified command in the same prompt. For example, if I type (see DEL or ERASEDEL or ERASE):
doskey dumpling=del "C:\a.txt"
This means that if (in the same prompt) I write DUMPLING
, the file C:\a.txt
will be deleted.
4. Define the BIGECHO
macro, which displays the specified string followed by an exclamation point (see ECHOECHO):
doskey bigecho=echo $*!
bigecho hi handsome
which will display:
hi handsome!
5. Create the macro KONG
, which, when executed, after greeting the user and nicely introducing itself, will insert the string banana
at the end of each file in the current directory (see FORFOR):
doskey kong=@echo Hello everyone, I'm Doskey Kong! I'm that big ape who will stick his banana inside every single file of yours without any mercy! $T @for %d in (*.*) do @(echo banana $G$G %d)
Further information:
To recall commands from the command line, you can use the up and down arrows: this allows you to select one of the last commands typed at the prompt. Typing F7 displays a screen with the command history and the relative indexes, which can be selected using the arrows; typing F9 instead displays a screen in which you are asked to enter the index associated with the command to recall. Typing F8 scrolls through the command history from the beginning of the buffer instead of from the end (as happens when using the arrows). Finally, the ESC key can be used to close the command history screens or to clear the contents of the command line.
The key combination Alt + F7 can be used to clear the command history (similar to DOSKEY /REINSTALL
, but without resetting the overwrite mode), while Alt + F10 will delete created macros (the latter function is not supported in the latest versions of Windows).
Comments