How to Access Command History in Command Prompt on Windows 10
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.
Using the Command History menu:
- Open the Start menu and type cmd in the search bar. Click on the Command Prompt app to proceed.
- 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.
- 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.
- 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.
- 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:
- On the Command Prompt home screen, type in the command doskey /history and press Enter.
- 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:
- 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.
- 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.
- Press Windows key + E to open the File Explorer. Select the Local Disk C: to continue.
- The file would be present as a text document with the name of cmd_history. Click on it to open the file.
- You can now view the history of all your previously executed commands logged in this file.
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.
Stay in the loop
GET A DAILY DIGEST OF LATEST TECHNOLOGY NEWS
Straight to your inbox
Subscribe to our newsletter