Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Use doskey.exe in Windows 11: A Complete Guide

Doskey.exe is a command-line utility in Windows that enhances the capabilities of the command prompt (CMD) by providing command history and macro functionality. It allows users to create command shortcuts and recall previously executed commands, which can significantly improve productivity when working with the command line.

Understanding Doskey.exe

Doskey was originally introduced in MS-DOS and has been included in Windows operating systems ever since. It is particularly useful for users who frequently work with the command line, as it can save time and reduce repetitive typing.

How to Access Doskey in Windows 11

  1. Open Command Prompt:

    • Press Win + R, type cmd, and press Enter or click OK.
  2. Start Doskey:

    • Doskey is automatically loaded when you open a command prompt in Windows 11. You can confirm this by typing doskey /? to display the help information.

Practical Examples

Example 1: Viewing Command History

To view the command history in the current session, use the following command:

doskey /history

This command will display a list of all commands entered during the current session.

Example 2: Creating Macros

You can create macros to simplify complex commands. For example, if you frequently navigate to a specific directory, you can create a macro for it:

doskey gotodocs=cd C:\Users\YourUsername\Documents

Now, typing gotodocs in the command prompt will take you directly to the Documents directory.

Example 3: Saving and Loading Command History

To save your command history to a file, use:

doskey /history > history.txt

To load commands from a file into the current session, use:

doskey /macrofile=history.txt

This can be particularly useful if you want to reuse a set of commands across different sessions.

Example 4: Creating a Persistent Macro

To make a macro persistent across sessions, you can add it to the command prompt's startup properties:

  1. Right-click on the Command Prompt title bar and select "Properties".
  2. In the "Shortcut" tab, add your doskey macro to the "Target" field. For example:
    %SystemRoot%\system32\cmd.exe /k doskey gotodocs=cd C:\Users\YourUsername\Documents

This ensures that your macro is available every time you open a new command prompt window.

Additional Tips

  • Editing Macros: To edit a macro, redefine it using the same syntax.
  • Deleting Macros: To delete a macro, close the command prompt session. Macros are not persistent unless added to the startup properties.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.