On BNET: 3 worst things about the iPhone 3G S

Create macros with the DOSKEY utility in Windows NT

Tags: Microsoft Windows NT, command line, TechRepublic Staff, Microsoft Windows, Doskey, Windows NT Newsletter

  • Save
  • Print
  • Recommend
  • 0

Takeaway: The DOSKEY utility allows you to create simple but powerful macros. Learn more about this powerful utility.

The command line is one of the most neglected parts of Windows NT, and many users aren't aware of everything it can do. For example, how many of your users can create a macro?

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.

DOSKEY [macroname=[command]]

Let's look at some sample macros.

DOSKEY c=cls

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.

  • Save
  • Print
  • Recommend
  • 0

Print/View all Posts Comments on this article

Programming with DOSKey WA2MCSwsm@... | 06/30/05

What do you think?

White Papers, Webcasts, and Downloads

Article Categories

Security
Security Solutions, IT Locksmith
Networking and Communications
E-mail Administration NetNote, Cisco Routers and Switches
CIO and IT Management
Project Management, CIO Issues, Strategies that Scale
Desktops, Laptops & OS
Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
Data Management
Oracle, SQL Server
Servers
Windows NT, Linux NetNote, Windows Server 2003
Career Development
Geek Trivia
Software/Web Development
Web Development Zone, Visual Basic, .NET

SmartPlanet

advertisement
Click Here