Create cmd.exe Aliases with doskey

doskey macros are cmd.exe's answer to bash aliases — short names for long commands, with $* for arguments.

WindowscmdaliascliLow risk
Run doskey name=command $* to define a macro; $* passes trailing arguments through to the command.

01Command

Command
$ doskey ll=dir /od $* ; doskey gs=git status $*

02What it does

cmd.exe has no native alias command, but doskey macros fill the role, including parameter substitution: $1-$9 grab individual arguments and $* passes the whole tail. The catch everyone forgets: macros live only in the cmd.exe process that created them, so they vanish when the window closes. Persist them by saving with doskey /macros > macros.cmd and loading via /macrofile in an AutoRun registry value (HKCU\Software\Microsoft\Command Processor).

03Risk

RiskLow risk
RequirementsMacros exist only for the current cmd.exe session; load them persistently via an AutoRun registry value pointing to a macro file
!Warning: doskey macros die with the console session unless loaded from a macrofile via AutoRun.

04Undo

Undo
$ doskey ll= ; doskey gs=

05Sources

  • Doskey - Create macros
    SS64 · technical · 2026-09-17
    Evidence: Explains macro scoping: macros are per-console and can be made persistent through AutoRun registry entries or /macrofile.
  • doskey (Windows Commands)
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Documents doskey macro syntax, the $* parameter for trailing arguments, and /macrofile for loading saved macros.

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

06Related solutions