Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ doskey(CMD) — OpenDesktop 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought


 doskey(CMD)                     19 June 1992                     doskey(CMD)


 Name

    doskey - recall MS-DOS commands, edit command lines, and create macros

 Syntax


    doskey [/reinstall] [/bufsize=size] [/macros] [/history]
    [/insert|/overstrike] [macroname=[text]]

    To start the doskey program and use the default settings, use the follow-
    ing syntax:

    doskey


 Description

    The doskey program is a terminate-and-stay-resident program.  You can use
    doskey to customize and automate MS-DOS command lines.  When installed,
    doskey occupies about 3 kilobytes of resident memory.

 Parameter


    macroname=[text]
                  Creates a macro that carries out one or more MS-DOS  com-
                  mands (a doskey macro).  macroname specifies the name you
                  want to assign to the macro.  text specifies the commands
                  you want to record.


 Switches


    /reinstall    Installs a new copy of the doskey program, even if one is
                  already installed.  In the latter case, the /reinstall
                  switch also clears the buffer.

    /bufsize=size Specifies the size of the buffer in which doskey stores
                  commands and doskey macros.  The default size is 512 bytes.
                  The minimum buffer size is 256 bytes.

    /macros       Displays a list of all doskey macros.  You can use a
                  redirection symbol (>) with the /macros switch to redirect
                  the list to a file.  You can abbreviate the /macros switch
                  as /m.

    /history      Displays a list of all commands stored in memory.  You can
                  use a redirection symbol (>) with the /history switch to
                  redirect the list to a file.  You can abbreviate the /his-
                  tory switch as /h.

    /insert|/overstrike
                  Specifies whether new text you type is to replace old text.
                  If you use the /insert switch, new text that you type on a
                  line is inserted into old text (as if you had pressed the
                  Ins key).  If you use the /overstrike switch, new text
                  replaces old text.  The default setting is /overstrike.


 Notes


    Recalling a command

    To recall a command, you can use any of the following keys after loading
    doskey into memory:

    Up Arrow      Recalls the MS-DOS command you used before the one dis-
                  played.

    Down Arrow    Recalls the MS-DOS command you used after the one dis-
                  played.

    PgUp          Recalls the oldest MS-DOS command you used in the current
                  session.

    PgDn          Recalls the most recent MS-DOS command you used.


    Editing the command line

    With the doskey program, you can edit the current command line.  The fol-
    lowing list describes the doskey editing keys and their functions:

    Left Arrow    Moves the cursor back one character.

    Right Arrow   Moves the cursor forward one character.

    CtrlLeft Arrow
                  Moves the cursor back one word.

    CtrlRight Arrow
                  Moves the cursor forward one word.

    Home          Moves the cursor to the beginning of the line.

    End           Moves the cursor to the end of the line.

    Esc           Clears the command from the display.

    F1            Copies one character from the template to the MS-DOS com-
                  mand line.  (The template is a memory buffer that holds the
                  last command you typed.)

    F2            Searches forward in the template for the next key you type
                  after pressing F2.  doskey inserts the text from the tem-
                  plate up to but not including the character you specify.

    F3            Copies the remainder of the template to the command line.
                  doskey begins copying characters from the position in the
                  template that corresponds to the position indicated by the
                  cursor on the command line.

    F4            Deletes characters, beginning with the first character in
                  the template, up to a character you specify.  To use this
                  editing key, you press F4 and type a character.  doskey
                  deletes up to, but not including, that character.

    F5            Copies the current command into the template and clears the
                  command line.

    F6            Places an end-of-file character (CtrlZ) at the end of the
                  current command line.

    F7            Displays all commands stored in memory, with their associ-
                  ated numbers.  doskey assigns these numbers sequentially,
                  beginning with 1 for the first (oldest) command stored in
                  memory.

    AltF7         Deletes all commands stored in memory.

    F8            Searches memory for a command that you want doskey to dis-
                  play.  To use this editing key, type the first character,
                  or the first few characters, of the command you want doskey
                  to search for and then press F8.  doskey displays the most
                  recent command that begins with the text you typed.  Press
                  F8 repeatedly to cycle through all the commands that start
                  with the characters you specified.

    F9            Prompts you for a command number and displays the command
                  associated with the number you specify.  To display all the
                  numbers and their associated commands, press F7.

    AltF11        Deletes all macro definitions.


    Specifying a default insert mode

    If you press the Ins key, you can type text on the doskey command line in
    the middle of old text without replacing the old text.  However, once you
    press Esc, doskey returns your keyboard to replace mode.  You must press
    Ins again to return to insert mode.

    The /insert switch puts your keyboard in insert mode each time you press
    Esc.  Your keyboard effectively remains in insert mode until you use the
    /overstrike switch.  You can temporarily return to replace mode by press-
    ing the Ins key; but once you press Esc, doskey returns your keyboard to
    insert mode.

    The cursor changes shape when you use the Ins key to change from one mode
    to the other.

    Creating a macro

    You can use the doskey program to create macros that carry out one or
    more MS-DOS commands.

    You can use the following special characters to control command opera-
    tions when defining a macro:

    $G or $g      Redirects 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$g  Appends output to the end of a file.  Use either of these
                  special double characters to append output to an existing
                  file rather than replace the data in the file.  These dou-
                  ble characters are equivalent to the ``append'' redirection
                  symbol for output (>>).

    $L or $l      Redirects input.  Use either of these special characters to
                  read input from a device or a file instead of from the key-
                  board.  This character is equivalent to the redirection
                  symbol for input (<).

    $B or $b      Sends macro output to a command.  Using one of these spe-
                  cial characters is equivalent to using the pipe (|) on a
                  command line.

    $T or $t      Separates commands.  Use either of these special characters
                  to separate commands when you are creating macros or typing
                  commands on the doskey command line.

    $$            Specifies the dollar-sign character ($).

    $1 through $9 Represent any command-line information you want to specify
                  when you run the macro.  The special characters $1 through
                  $9 are batch parameters, which make it possible for you to
                  use different data on the command line each time you run
                  the macro.  The $1 character in a doskey command is similar
                  to the %1 character in a batch program.

    $*            Represents all the command-line information you want to
                  specify when you type the macro name.  The special charac-
                  ter $* is a replaceable parameter that is similar to the
                  batch parameters $1 through $9, with one important differ-
                  ence.  Here, everything you type on the command line after
                  the macro name is substituted for the $* in the macro.

    For example, to create a macro that performs a quick and unconditional
    format of a disk, type the following command:

       doskey qf=format $1 /q /u


    For information about quick and unconditional formatting, see the
    format(CMD) command.

    You can use the doskey command in a batch program to create a macro.

    Running a 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 pa-
    rameters $1 through $9, use a space to separate parameters.

    You could run the qf macro created in the previous example to format a
    disk in drive A quickly and unconditionally.  To do so, you would type
    the following command:

       qf a:


    You cannot run a macro from a batch program.

    Creating a macro with the same name as an MS-DOS command

    You might want to create a macro that has the same name as an MS-DOS com-
    mand.  This can be useful, for example, if you always use a certain com-
    mand with specific switches.  To specify whether you want to run the
    macro or the MS-DOS command, follow these guidelines:

    +  To run the macro, begin typing the macro name immediately after the
       command prompt, with no space between the prompt and the command name.

    +  To carry out the command, insert one or more spaces between the com-
       mand prompt and the command name.


    Deleting a macro

    To delete a macro type the following command:

       doskey macroname=


 Examples

    The /macros and /history switches are useful for creating batch programs
    to save macros and commands.  For example, to create a batch program
    named MACINIT.BAT that includes all doskey macros, type the following
    command:

       doskey /macros > macinit.bat


    To use the MACINIT.BAT file, edit it to include the doskey command at the
    beginning of each macro line.

    To create a batch program named TMP.BAT that contains recently used com-
    mands, type the following command:

       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, using the wide display for-
    mat.  You can use $* at the end of the macro to append other switches to
    the dir command when you run tx.

    The following macro uses a batch parameter for a new directory name.  The
    macro first creates a new directory and then changes to it from the
    current directory.

       doskey mc=md $1$tcd $1


    To use the preceding macro to create and change to a directory named
    BOOKS, you type the following:

       mc books


    To create a macro that uses batch parameters for moving a file or group
    of files, type the following command:

       doskey mv=copy $1 $2 $t del $1


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026