The Windows command prompt, or cmd.exe, is a powerful tool that can be used to automate many tasks. One of the most useful tools available in cmd.exe is the DOSKEY command. DOSKEY enables users to create permanent command macros that can be used to quickly execute longer commands. This can save time and reduce the amount of typing required for frequently used commands. In this article, we will explain how to create permanent DOSKEY macros in Windows cmd.exe.
The DOSKEY command works by creating a macro, or command shortcut, which can be used to quickly execute longer commands. A DOSKEY macro consists of a single command, or multiple commands separated by semicolons. When the macro is executed, the commands associated with it are executed as though they had been typed into the command line.
The DOSKEY command can be used to create permanent macros that will be available every time cmd.exe is opened. To do this, the DOSKEY command must be used with the /MACROFILE switch. This switch allows the user to specify a text file containing one or more DOSKEY macros. When the command prompt is opened, the macros specified in the text file are automatically loaded and made available to the user.
To create a permanent DOSKEY macro, first create a text file in any text editor. The text file should contain one or more DOSKEY commands, one per line. Each command should be written in the same format as it would be typed into the command line. For example, if you wanted to create a DOSKEY command to quickly execute the command “dir /s /b”, the text file would contain the following line:
dir /s /b
Once the text file has been created, it can be used with the DOSKEY command to create the permanent macro. The command to do this is as follows:
After the DOSKEY command has been executed, the macro is available in the command prompt. To execute the macro, simply type the name of the macro (in this example, “dir”) and press enter. The commands associated with the macro will be executed.
The DOSKEY command can be used to create multiple permanent macros by specifying multiple text files. For example, the following command will create two permanent DOSKEY macros:
The DOSKEY command can also be used to delete existing permanent macros using the /REINSTALL switch. This switch will delete all existing DOSKEY macros and reload the macros specified in the text files.
The DOSKEY command is a powerful tool for automating tasks in the Windows command prompt. By using the /MACROFILE switch, IT admins can create permanent DOSKEY macros that can be used to quickly execute longer commands, saving time and effort.