Windows NT includes a powerful DOSKEY utility that allows you to create simple but powerful macros. It even features the ALIASES command. When you enter a command, the shell checks if there's a DOSKEY macro present in memory before checking for internal commands.
Here's the basic syntax for DOSKEY macros. To access all other options, enter DOSKEY /? at the command prompt.
Let's look at some sample macros.
This macro allows you to enter c at the command prompt instead of cls to clear the screen.
DOSKEY d=dir /o /p $*
This macro displays the contents of the folder, listed alphabetically one screen at a time.
You can also run more than one command with a macro. Here's an example:
DOSKEY nd=md $1$Tcd $1
Entering nd myfolder creates a new folder (myfolder) and switches to it. This is basically the same as entering the md myfolder and cd myfolder commands separately.
Once you create your collection of macros, save them to a file. To do so, enter DOSKEY /macros > filename.
You can load them into memory by entering DOSKEY /macrofile=filename. This is especially useful because macros don't persist through the session, meaning they're lost once you close the command prompt. By storing them in a file, you can easily reload them later. If you want to delete a macro from memory, enter DOSKEY macroname =.
However, macros do have limitations. For example, you can't run them from a batch file. In addition, their powerful nature can render the command prompt completely inoperable. For instance, you could create macros that have the same names as commands, such as DIR, COPY, and even DOSKEY itself.