Speeding Up MS‑DOS Workflows with DOSKEY Aliases
Learn how to create, persist, and use DOSKEY aliases in MS‑DOS, including correct syntax, macro arguments, batch‑file considerations, and a practical AUTOEXEC.BAT example.
23 Aug 2025, 14:10 UTC

Problem: Repetitive Typing in a 640 KB World
In a plain MS‑DOS prompt every command is typed manually. Common patterns—listing directories, copying files, deleting temporary data—quickly become a source of keystrokes and errors. The built‑in DOSKEY utility offers a lightweight way to create short aliases and macros, but many users discover that the aliases disappear after closing the prompt or that they cannot be used inside batch files without extra work.
Thesis: DOSKEY is the right tool, but you must understand its syntax, persistence, and inheritance rules to avoid pitfalls.
1. Alias Syntax and Macro Arguments
The basic form is:
DOSKEY alias=command
Examples:
DOSKEY ll=DIR /B /A:D– lists only directories in bare format.DOSKEY copyfile=COPY $1 $2– copies the first argument to the second.
When a macro uses arguments, $1 through $9 represent the first to ninth words typed after the alias. $* expands to the entire argument string. Special tokens include $T (current time), $E (escape character), and $G (the ‘>’ character).
2. Making Aliases Persistent
Aliases live only in the current command session. To make them available every time MS‑DOS boots, add the DOSKEY lines to AUTOEXEC.BAT (or a script that AUTOEXEC.BAT calls). The file must reside in the root of the active drive and be executed before the command prompt appears.
- Open
AUTOEXEC.BATin a plain text editor. - Add the alias definitions, e.g.
DOSKEY ll=DIR /B /A:D. - Save and reboot.
- Open a command prompt and type
llto confirm the alias works. - Run
DOSKEY /Lto list all active aliases and verify persistence.
Checking the Result
After booting, the command DOSKEY /L will print each alias on its own line. If an alias is missing, double‑check that AUTOEXEC.BAT is on the correct drive and that no syntax errors (e.g. stray spaces around the equals sign) exist.
3. Using Aliases Inside Batch Files
Batch files do not automatically inherit DOSKEY aliases. To use an alias inside a batch script you must first define it in that context or use the full command. A common pattern is:
@echo off
REM Define the alias for this batch run
DOSKEY copyfile=COPY $1 $2
REM Now the alias is usable
copyfile %1 %2
Because the alias is defined only for the current batch execution, it does not affect other command prompts. If you need the alias globally, keep it in AUTOEXEC.BAT.
4. Practical Example: A Minimal AUTOEXEC.BAT
Below is a ready‑to‑copy example that defines three useful aliases and demonstrates persistence. Place this file on the root of your boot drive before rebooting.
@echo off
REM --- Alias definitions ---
DOSKEY ll=DIR /B /A:D
DOSKEY ls=DIR /B
DOSKEY copyfile=COPY $1 $2
REM --- End of aliases ---
After reboot:
- Typing
lllists only directories. - Typing
lslists all files and directories. - Running
copyfile file1.txt file2.txtcopiesfile1.txttofile2.txt.
5. Trade‑offs and Limitations
- Session‑Only by Default: Without
AUTOEXEC.BATthe aliases vanish after the prompt closes. - Memory Footprint: Each alias consumes a few bytes of conventional memory. On very small systems you may hit the 640 KB ceiling if you define many aliases.
- Batch Inheritance: Batch files must explicitly define the alias or use the full command; otherwise the alias is unknown.
- Availability:
DOSKEYships with MS‑DOS 5.0 and later, and also with the Windows NT/2000/XP command prompt. The syntax is identical, but the environment may differ (e.g., Windows uses a different memory model). - Comment Syntax: In batch files comments start with
REMor::; the hash symbol (#) is not a comment character.
6. Actionable Checklist
- List the commands you use most frequently.
- Draft
DOSKEYlines with appropriate macro arguments. - Add them to
AUTOEXEC.BAT(or a dedicated startup script). - Reboot and run
DOSKEY /Lto confirm persistence. - Test each alias in a fresh command prompt.
- If you need to use an alias inside a batch file, include a
DOSKEYdefinition at the top of that file. - Monitor memory usage on very small systems; if you hit the 640 KB limit, reduce the number of aliases.
By following these steps you can turn a clunky MS‑DOS prompt into a quick‑access toolbox that saves keystrokes and reduces typing errors.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.