How To Check Command Prompt History In Windows

See and save preview of latest commands entered in the command prompt. View command prompt history using these 3 ways.

Command Prompt (cmd) is a widely used command-line tool for Windows. Although Microsoft has released more tools like PowerShell and Windows Terminal, most users still like to use the Command Prompt for their daily command line tasks.

If you are using Command Prompt to run multiple commands, the CMD provides a convenient way to move backwards and forwards in the command history you have already typed using the Up and Down arrow keys.

To view cmd history, run the following command and press Enter.

doskey /history

This will list all previously executed commands in this session of Command Prompt.

There is no way to search through the command history and, secondly, the history is only saved for the current session. There is no persistent history of commands.

In this tutorial, we will discuss ways to see and search the list of your commands typed in cmd. We will also discuss ways to save the cmd history in a text file for future reference.

View Command Prompt History Using keyboard shortcut

You will only see the history for the current session in the Command Prompt window. Upon closing the Command Prompt window, all previous commands will be lost upon restarting the program.

Once you have opened the Command Prompt window and started executing commands, Windows will save the history for your active session.

To see the list of recently executed commands in CMD, press the F7 key. This will open a pop-up inside CMD showing the list of recently executed commands. You can select any command and press enter and that specific command will be executed again.

View command prompt history using F7 key

And after reaching to it, press Enter key. And here you are. Your command is executed.

How To Check Command Prompt History In Windows 1

Search cmd history using keyboard shortcut

You can also search for a specific command from your CMD history. To search for a specific command from the history, just press the F8 key, type whatever you remember and then press F8 key to cycle through the possibilities from the history.

For example, if the command I’m searching for starts with “ip“, I will type ip and then press the F8 key. Pressing F8 key again will bring another possible result from history, if any. Keep pressing F8 key again and again until the history list ends.

Execute commands from cmd history using keyboard shortcut

When we pressed the F7 key, you should have noticed that each command starts with a number. If you want to call a command again and again, you can call it by its number by using the F9 key.

For example, if the command number 3 is the one I have to run again and again, I will press F9 key, type 3 and then press Enter. This will execute the command no. 3 from the command history.

View Command Prompt History Using Doskey

To have the entire list of your Command Prompt window’s commands, on the window as a text, you have to type the following command in your CMD window.

Because sometimes, you do not like pop-up windows all the time. That’s why I am giving you an easy and clean way to see the history of your Command Prompt window.

Open CMD from the Start Menu and type “doskey /History”. As you typed, all the commands which you typed latterly are shown to you in your CMD window.

doskey /history
How To Check Command Prompt History In Windows 2

Use Up and Down arrow to select the command. Or you can also Copy and Paste the commands from the history that has appeared on your screen, within the CMD window.

How to save Command Prompt History

You can only view the history of commands as long as your CMD window stays open. When you close it, all commands will be gone with no mark of history. What if you need the same commands for the next use of CMD window, but you do not know which commands you executed before?

You can save your commands list as a TXT, HTML, CSV or RTF file before closing the window so that you can have a backup of your entered commands.

Type the following command in your Command Prompt window

doskey /HISTORY > history.txt

How To Check Command Prompt History In Windows 3

Your file will be saved in the Users folder. Now go to the user folder and see if that has the file saved there or not.

How To Check Command Prompt History In Windows 4

Please check the history of all commands and save them in a notepad file to use any of your commands anytime you need.

How to clear CMD history

Since the command history in CMD and PowerShell is not persistent, history can be cleared by closing the current CMD window. If you do not want to close the CMD window, you have to press Alt + F7 key. This will clear the CMD history from your current session.

View command history in PowerShell

PowerShell can also be used in place of the Command Prompt. PowerShell can run all the commands for CMD plus many more. If you want to view the history of your commands in PowerShell, you have to type the history command. This will show a list of all recently typed commands inside the current PowerShell session.

I hope you have a clear understanding of how to view your history in CMD and how to save that history. If you have any questions, comment below to ask.

Also see:

Itechtics staff is a team of technology experts led by Usman Khurshid. We verify everything we write so that our users can be sure to trust us in everything we write. You can reach out to us for further help and support.


  1. Vibhanshu says:

    How can we get the executed commands history if i have closed the session in command prompt?

  2. once you get to history can u delete the command prompts you want

  3. I tried doskey /h in Windows 10 cmd and — it works too!

  4. Thank you so much for the insight, it was a very good information for me. I would like to give your command “doskey /HISTORY > history.txt” a little tweak. If we will modify the command to doskey /HISTORY >> history.txt (two arrows instead of one) this will append all the commands from the point of execution. unlike the single arrow (>) where the file will be over written when you execute the command every time.

Leave a Reply

You have to agree to the comment policy.