Create command aliases in CMD with doskey

The forgotten bash-alias equivalent: define macros with $* argument passing, list them with /macros.

WindowscmddeveloperproductivityLow risk
Run doskey <name>=<command> $* to define an alias; doskey /macros lists all, doskey <name>= removes one.

01Command

Command
$ doskey ll=dir /b $*

02What it does

doskey macros expand before execution, and $* passes everything typed after the alias, while $1–$9 pass individual arguments — e.g. doskey ga=git add $1. Macros exist only in the current CMD session, so persistent setups load them from a file via doskey /macrofile=macros.txt, typically from an AutoRun registry entry. They are not real executables, so batch files and other programs can't call them.

03Risk

RiskLow risk
!Warning: Macros vanish when the CMD window closes — without an AutoRun setup every new session starts with none.

04Undo

Undo
$ doskey ll=

05Sources

  • doskey | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    Evidence: Microsoft documents doskey macro definition syntax including $1-$9 and $* for arguments, /macros to list them, and that macros apply only to the current session.
  • DOSKEY - Windows CMD
    SS64 · technical · 2026-09-17
    Evidence: SS64 documents $* argument substitution, /macros, /history, and loading macros from a file with /macrofile.

Last verified: 2026-09-17 · Category: Developer

06Related solutions