How to Access Command History in Command Prompt on Windows 10

Apr 20, 2020
Submit

Windows' Command Prompt enables you to run programs, batch files, automate tasks, and even perform administrative functions along with troubleshooting issues on Windows 10. Given the nature of its functionality for a frequent user, the command history feature is a plus as you can cycle between previously used commands and even log them as a .txt file in an active session.

However, the history cannot be restored if you exit Command Prompt as this feature works for the current working session only. This means that if the Command Prompt window is closed or if the PC restarts then the history is wiped out. Here are two ways to access and save the command history in Command Prompt on Windows 10.

Crysis Remastered Has A Benchmark Tool, Here’s How To Find It

Using the Command History menu:

  1. Open the Start menu and type cmd in the search bar. Click on the Command Prompt app to proceed.
    How to use command history in Command Prompt on Windows 10
  2. On the Command Prompt home screen, press the F7 key to access the menu which has all of your previously executed commands listed in chronological order.
  3. For instance, if you executed an auto-shutdown command as highlighted below and wish to disable it without typing in the same command over again.
    command history in CMD for windows 10
  4. Simply press F7 to bring up the command history and use the arrow up and down keys to navigate between the commands that you wish to use. Press Enter when you have selected the required command.
  5. This would execute the selected command in Command Prompt. You can also cycle between the previous commands by simply pressing the arrow up and down buttons.

Using Doskey History Command:

  1. On the Command Prompt home screen, type in the command doskey /history and press Enter.
    command history in CMD for windows 10
  2. This would list down all of the previously executed commands in that session on Command Prompt.

How to Save Command History in a .txt File:

Typically, the command history in Command Prompt on Windows 10 only works for the current session and you cannot access the history after you restart the computer. But you can save the command history in a .txt file on your computer either to keep a record of your commands or the changes that you made to your computer. Here’s how to do that:

  1. Open the Start menu and type cmd in the search bar. Right-click on the Command Prompt app and select Run as Administrator to proceed.
  2. Type the command doskey /h > c:\cmd_history.txt and press Enter. This would log your command history from Command Prompt in a .txt file on your C: drive.
    view command prompt history in Windows 10
  3. Press Windows key + E to open the File Explorer. Select the Local Disk C: to continue.
  4. The file would be present as a text document with the name of cmd_history. Click on it to open the file.
  5. You can now view the history of all your previously executed commands logged in this file.
    save command prompt history on Windows 10

The command history feature in Command Prompt can save you a fair amount of time along with the trouble of retyping commands in an active session.

Submit