Skip to content

DOSKEY Windows Command Guide

The DOSKEY command in Windows allows users to create macros, edit command lines, and recall previously entered commands easily. By enabling command line editing and history recall functionalities, DOSKEY helps optimize workflow and increase productivity for users who frequently work in the command prompt. This guide provides an overview of how to utilize DOSKEY, including how to create macros, edit commands, recall command history, and customize settings. With DOSKEY, users can streamline their command line tasks and work more efficiently in the Windows operating system.

DOSKEY Syntax:

Terminal window
doskey [macroname]=[command]

Options:

OptionDescription
macronameName of the macro to create
commandCommand to assign to the macro

Parameters:

ParameterDescription
macronameName of the macro
commandCommand to assign to the macro

DOSKEY Command Samples:

Create a Shortcut for Listing Directory Contents

Terminal window
doskey l=dir

Creates a shortcut “l” that executes the “dir” command to list the contents of a directory.

Create a Macro to Clear Screen and List Directory

Terminal window
doskey ldc=cls ^& dir

Creates a macro “ldc” that clears the screen and lists the directory contents in one command.

View All Defined Macros

Terminal window
doskey /macros

Displays a list of all defined macros for quick reference.

Create a Shortcut to Change Directory to C:

Terminal window
doskey cdC=cd /d C:\

Creates a shortcut “cdC” that changes to the C: drive’s root directory in a single command.

Define a Macro to Run Multiple Commands Sequentially

Terminal window
doskey update=echo Updating... ^& echo Please wait... ^& myScript.bat

Defines a macro “update” to display messages and then run a custom batch file named “myScript.bat”.

Remove a Defined Macro

Terminal window
doskey /R l

Removes the defined macro “l” that was set to execute the “dir” command.

Create a Shortcut for Opening Notepad

Terminal window
doskey np=notepad

Sets up a shortcut “np” to launch Notepad quickly with a single command.

DOSKEY FAQ:

How do I use doskey in Windows?

To use the doskey command in Windows, execute the following command:

Terminal window
doskey --option <value>

How can I create a macro with doskey?

To create a macro with doskey, use the following syntax:

Terminal window
doskey macro_name=command

How do I list all defined macros in doskey?

To list all defined macros in doskey, use the command:

Terminal window
doskey /macros

How do I recall a specific macro in doskey?

To recall a specific macro in doskey, use the command with the macro name preceded by a $ symbol:

Terminal window
$macro_name

How do I delete a specific macro in doskey?

To delete a specific macro in doskey, use the command:

Terminal window
doskey macro_name=

Can doskey be used to repeat previous commands?

Yes. By pressing the F3 key in the CMD prompt, doskey will recall the most recent command you executed.

Applications of the DOSKEY Command

  1. Creating macros for commonly used commands
  2. Defining aliases for long and complex commands
  3. Listing and recalling previous commands with modifications
  4. Increasing efficiency and productivity in the Command Prompt
  5. Simplifying command line tasks with shortcuts
  6. Customizing the Command Prompt experience