DOSKEY is a command-line utility for Windows that enables users to recall, edit, and execute previously entered commands from the Command Prompt. It also allows the creation of macros, which are aliases or shortcuts for longer command sequences. This utility is particularly useful in command-line heavy tasks where repeated commands are common, such as in system administration or software development environments.


The basic syntax for using DOSKEY is as follows:

DOSKEY [/REINSTALL] [/LISTSIZE=size] [/MACROS] [/HISTORY] [/INSERT | /OVERSTRIKE] [/EXENAME=exename] [/MACROFILE=filename] [macroName=[text]]
  • /REINSTALL: Installs a new copy of DOSKEY and clears the command history.
  • /LISTSIZE=size: Sets the number of commands that DOSKEY will remember.
  • /MACROS: Displays all DOSKEY macros.
  • /HISTORY: Displays all commands stored in the buffer
  • /INSERT | /OVERSTRIKE: Toggles between insertion and overstrike mode.
  • /EXENAME=exename: Specifies the executable.
  • /MACROFILE=filename: Specifies a file of macros to install.
  • macroName=[text]: Creates a macro that runs the specified text.


  • /REINSTALL: Clears the command history and reloads DOSKEY, helpful when command history becomes cluttered.
  • /LISTSIZE=size: Useful for increasing or decreasing the buffer size to tailor the command history capacity.
  • /MACROS: Useful for reviewing all defined macros, especially when debugging complex macro setups.
  • /HISTORY: Useful for reviewing recent command inputs, aiding in repetitive task execution.
  • /INSERT: Sets DOSKEY to insertion mode, which inserts text rather than overwriting existing text.
  • /OVERSTRIKE: Sets DOSKEY to overstrike mode, where new input overwrites existing text under the cursor.
  • /EXENAME=exename: Applies DOSKEY functionality to the specified executable, useful for managing commands in specific applications.
  • /MACROFILE=filename: Loads macros from a specified file at startup, allowing for complex macro setups to be easily distributed and reused.


  1. View command history:

  2. Create a simple macro:

    DOSKEY compile=gcc $1 -o $2

    This macro compiles a C program using gcc.

  3. Load macros from a file:

    DOSKEY /MACROFILE=c:\macros.txt

    Loads macros defined in macros.txt into the current session.

  4. Clear command history and reinstall DOSKEY:


Common Issues

  • Macros Not Persisting: DOSKEY macros are session-specific and do not persist through different instances of Command Prompt. To maintain macros across sessions, save them in a file and load them using the /MACROFILE=filename option.
  • Syntax Errors in Macros: Errors can occur if the macro syntax is not correct. Check for typing errors, especially with special characters used to denote parameters $1, $2, etc.


DOSKEY can be effectively combined with batch scripts to automate repetitive tasks. Here’s an example of a batch script that initializes DOSKEY with predefined macros:

@echo off
DOSKEY /MACROFILE=c:\startup_macros.txt
REM Additional commands or scripts can follow here
  • CMD: The command processor used to execute commands and scripts in Windows.
  • Powershell: An advanced command-line shell and scripting language with more features than CMD.

For more information on DOSKEY and related utilities, visit the official Microsoft documentation pages available online.