how do you make a macro in command prompt..?

i know somewhat how to set it up like you need to type in :

doskey macroname for the name

and doskey text for what you need it to do

how do you do this or where is a good website to tell me

thanks

jd b

1 Answer

Relevance
  • 1 decade ago
    Best Answer

    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 =.

    Note: macros do have limitations:

    1) 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.

    2) DOSKEY Macros Must Be Executed from the Command Prompt. It is not possible for a program or batch file to execute a DOSKEY macro. All DOSKEY macros must be executed from the command prompt. For more about this restriction, check out this Microsoft Help and Support page: http://support.microsoft.com/kb/79245.

Still have questions? Get your answers by asking now.