Command Prompt or CMD is a command-line tool on Windows. The command history of the Command Prompt is a history of all the commands we have typed in a particular session. Most users see their recent commands in Command Prompt by manually clicking the Arrow keys up and down. However, there is a much easier way to view this command history and export it to an external text file. So, read along to learn how to use this Windows command history feature and make your life much easier while using the Command Prompt.

Steps to use Windows Command Prompt History

  • Press the Start button on your keyboard
  • Type “Command” inside the search bar and click the Command Prompt application
Search Command Prompt
Search Command Prompt
  • Press the F7 key on your keyboard once the Command Prompt window opens. You will see a command history window similar to the one highlighted below
Command History on pressing F7
Command History on pressing F7
  • Another way to open the command history window is by typing a command in Command Prompt. If the F7 key method doesn’t work for some reason, type the following command inside your Command Prompt window:
doskey /history
  • You will get the command history inside your Command Prompt window as an output. You can see the result from the screenshot attached below
View command history with command
View command history with command
  • You can also export the command history to an external text file. For this, just type the command the same as below and your command history will be exported
doskey /h > C:\cmd_history.txt
  • The above command will create a new text file named cmd_history.txt on your PC and write the command history to it. This file can be accessed from “C:\cmd_history.txt”. We have attached a screenshot of the sample text file of our exported command history for reference
command history list on notepad
command history text file
  • That’s it. You have just viewed your command history and exported the command history into an external text file.

In case you have doubts regarding this tutorial, feel free to comment below with your questions. We will make sure to solve them in the best way possible.

Read Next: How to Clear Command Prompt Screen and Command History

Was this Article helpful?
YesNo