Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

doskey

Feedback

In this article

Calls Doskey.exe, which recalls previously entered command-line commands, edits command lines, and creates macros.

Syntax

doskey [/reinstall] [/listsize=<size>] [/macros:[all | <exename>] [/history] [/insert | /overstrike] [/exename=<exename>] [/macrofile=<filename>] [<macroname>=[<text>]]

Parameters

ParameterDescription
/reinstallInstalls a new copy of Doskey.exe and clears the command history buffer.
/listsize=<size>Specifies the maximum number of commands in the history buffer.
/macrosDisplays a list of alldoskey macros. You can use the redirection symbol (>) with/macros to redirect the list to a file. You can abbreviate/macros to/m.
/macros:allDisplaysdoskey macros for all executables.
/macros:<exename>Displaysdoskey macros for the executable specified byexename.
/historyDisplays all commands that are stored in memory. You can use the redirection symbol (>) with/history to redirect the list to a file. You can abbreviate/history as/h.
/insertSpecifies that new text you type is inserted in old text.
/overstrikeSpecifies that new text overwrites old text.
/exename=<exename>Specifies the program (that is, executable) in which thedoskey macro runs.
/macrofile=<filename>Specifies a file that contains the macros that you want to install.
<macroname>=[<text>]Creates a macro that carries out the commands specified byText.MacroName specifies the name you want to assign to the macro.Text specifies the commands you want to record. IfText is left blank,MacroName is cleared of any assigned commands.
/?Displays help at the command prompt.

Remarks

  • 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 overridedoskey key assignments. For example, if the program uses the F7 key for a function, you cannot get adoskey command history in a pop-up window.

  • You can use Doskey.exe to edit the current command line, but you can't use the command-line options from a program's command prompt. You must rundoskey command-line options before you start a program. If you use Doskey.exe within a program, that program's key assignments take precedence and some Doskey.exe editing keys might not work.

  • With Doskey.exe, you can maintain a command history for each program that you start or repeat. You can edit previous commands at the program's prompt, and startdoskey 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.

  • To recall a command, you can use any of the following keys after you start Doskey.exe:

    KeyDescription
    UP ARROWRecalls the command that you used before the one that is displayed.
    DOWN ARROWRecalls the command that you used after the one that is displayed.
    PAGE UPRecalls the first command that you used in the current session.
    PAGE DOWNRecalls the most recent command that you used in the current session.
  • The following table listsdoskey editing keys and their functions:

    Key or key combinationDescription
    LEFT ARROWMoves the insertion point back one character.
    RIGHT ARROWMoves the insertion point forward one character.
    CTRL+LEFT ARROWMoves the insertion point back one word.
    CTRL+RIGHT ARROWMoves the insertion point forward one word.
    HOMEMoves the insertion point to the beginning of the line.
    ENDMoves the insertion point to the end of the line.
    ESCClears the command from the display.
    F1Copies one character from a column in the template to the same column in the Command Prompt window. (The template is a memory buffer that holds the last command you typed.)
    F2Searches forward in the template for the next key that you type after you press F2. Doskey.exe inserts the text from the template up to, but not including, the character you specify.
    F3Copies the remainder of the template to the command line. Doskey.exe begins copying characters from the position in the template that corresponds to the position indicated by the insertion point on the command line.
    F4Deletes all characters from the current insertion point position up to, but not including, the next occurrence of the character that you type after you press F4.
    F5Copies the template into the current command line.
    F6Places an end-of-file character (CTRL+Z) at the current insertion point position.
    F7Displays (in a dialog box) all commands for this program that are stored in memory. Use the UP ARROW key and the DOWN ARROW key to select the command you want, and press ENTER to run the command. You can also note the sequential number in front of the command and use this number in conjunction with the F9 key.
    ALT+F7Deletes all commands stored in memory for the current history buffer.
    F8Displays all commands in the history buffer that start with the characters in the current command.
    F9Prompts you for a history buffer command number, and then displays the command associated with the number that you specify. Press ENTER to run the command. To display all the numbers and their associated commands, press F7.
    ALT+F10Deletes all macro definitions.
  • If you press the INSERT key, you can type text on thedoskey command line in the midst of existing text without replacing the text. However, after you press ENTER, Doskey.exe returns your keyboard toReplace mode. You must press INSERT again to return toInsert mode.

  • The insertion point changes shape when you use the INSERT key to change from one mode to the other.

  • If you want to customize how Doskey.exe works with a program and createdoskey macros for that program, you can create a batch program that modifies Doskey.exe and starts the program.

  • You can use Doskey.exe to create macros that carry out one or more commands. The following table lists special characters that you can use to control command operations when you define a macro.

    CharacterDescription
    $G or$gRedirects output. Use either of these special characters to send output to a device or a file instead of to the screen. This character is equivalent to the redirection symbol for output (>).
    $G$G or$g$gAppends output to the end of a file. Use either of these double characters to append output to an existing file instead of replacing the data in the file. These double characters are equivalent to the append redirection symbol for output (>>).
    $L or$lRedirects input. Use either of these special characters to read input from a device or a file instead of from the keyboard. This character is equivalent to the redirection symbol for input (<).
    $B or$bSends macro output to a command. These special characters are equivalent to using the pipe( and*.
    $T or$tSeparates commands. Use either of these special characters to separate commands when you create macros or type commands on thedoskey command line. These special characters are equivalent to using the ampersand (&) on a command line.
    $$Specifies the dollar-sign character ($).
    $1 through$9Represent any command-line information you want to specify when you run the macro. The special characters$1 through$9 are batch parameters that enable you to use different data on the command line each time you run the macro. The$1 character in adoskey command is similar to the%1 character in a batch program.
    $*Represents all the command-line information that you want to specify when you type the macro name. The special character$* is a replaceable parameter that is similar to the batch parameters$1 through$9, with one important difference: everything you type on the command line after the macro name is substituted for the$* in the macro.
  • To run a macro, type the macro name at the command prompt, starting at the first position. If the macro was defined with$* or any of the batch parameters$1 through$9, use a space to separate the parameters. You cannot run adoskey macro from a batch program.

  • 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:

    • To run the macro, type the macro name at the command prompt. Do not add a space before the macro name.

    • To run the command, insert one or more spaces at the command prompt, and then type the command name.

Examples

The/macros and/history command-line options are useful for creating batch programs to save macros and commands. For example, to store all currentdoskey 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 todir when you run the tx option.

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 the new directory from the current directory.

To use the preceding macro to create and change to a directory namedBooks, type:

mc books

To create adoskey macro for a program calledFtp.exe, include/exename as follows:

doskey /exename=ftp.exe go=open 172.27.1.100$tmget *.TXT c:\reports$tbye

To use the preceding macro, start FTP. At the FTP prompt, type:

go

FTP runs theopen,mget, andbye commands.

To create a macro that quickly and unconditionally formats a disk, type:

doskey qf=format $1 /q /u

To quickly and unconditionally format a disk in drive A, type:

qf a:

To delete a macro calledvlist, type:

doskey vlist =

Related links


Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

  • Last updated on

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?