Tip: Simplify Command Entry with Doskey Macros

The Doskey utility lets you encapsulate command strings as easy-to-enter macros. For example, by typing the following at the command prompt:

Follow Our Daily Tips

RSS | Twitter | Blog | Facebook

Tell Us Your Tips

Share your tips and tweaks.

doskey 50=mode con:lines=50

you create a macro named 50 that executes the command string mode con:lines=50.To run a macro, you simply enter its name (in this example, 50) at a command prompt. You can create as many macros as you like with Doskey, but your macros are effective only for the current Command Prompt session.

To create a reusable set of Doskey macros, save them in a plain-text file, using an editor such as Notepad. Then load them from the command prompt, using Doskey’s /Macrofile switch. For example, if your macros are stored in your profile folder in a file named MyMacros.txt, typing:

doskey /macrofile=%userprofile%\mymacros.txt

makes those macros available for the current Command Prompt session. And if you regularly use the same macro file, you might want to consider using the AutoRun feature to load your macros.

For more information about using Doskey, type doskey /? at the command prompt.

From the Microsoft Press book Windows 7 Inside Out by Ed Bott, Carl Siechert, and Craig Stinson.

Looking for More Tips?

For more tips on Windows 7 and other Microsoft technologies, visit the TechNet Magazine Tips library.