How to view, save and clear Command Prompt command History in Windows

The Command Prompt is nothing but a black and white command line utility that comes out of the box on Windows 10/8/7. But those who know its true potential, it is a great replacement for many of the users’ third-party software. For example, it can help you in organizing your hard drive partitions, create a bootable USB drive for you, refresh all the BIOS files, and much more. Many administrators and power users tend to make use of multiple commands on this command line to get their work done. Today, we will be talking about 2 methods that will help the user view their Command Prompt history and one method to save that Command Prompt history on Windows 10.

View, save, clear Command Prompt command History

We will cover the following topics:

  1. View using DOSKEY.
  2. View using the F7 key.
  3. Save the Command Prompt History.
  4. Clear command prompt history.

1] View command history using DOSKEY

This method is a pretty straightforward one. After you have entered a series of commands in the Command Prompt window, all you need to do is enter the following command inside the same Command Prompt window-

doskey /history

After that, you will be able to check all the commands that you just entered during that session in the Command Prompt in the same sequence as you entered it.

You can check a screen snippet of the same above.

2] View CMD history using the F7 key

How to view, save and clear Command Prompt command History in Windows

This is better than the DOSKEY method mentioned above. I am not claiming that because this is better, but if you just want to get back to any previously executed command, it is really reliable.

To view the command history, you need to hit the F7 key. F7 works for Command Prompt and PowerShell as well.

This will lead to a small pop-up to appear with the list of all the previously executed commands in the session.

You can use the up and down arrow key to navigate through the list and hit the Enter key to select any of them.

2] Save the Command Prompt History

Sometimes, you might need to keep a record of the commands they used in a session using the Command Prompt in a TXT, HTML, CSV or a RTF file.

For that, you can use an extension of the DOSKEY command.

You just need to enter the following command and then hit  the Enter key,

doskey /HISTORY > SampleHistory.txt

Then, your backed up history file will be saved in a location where you executed the command in the Command Prompt window.

4] Clear command prompt history using Alt+F7

The simplest way is to restart the Command Prompt. The command history is cleared automatically every time you close it and start the command prompt again.

To clear the command history, you can alsoe use Alt+F7 keyboard shortcut. Alt+F7 works for Command Prompt and PowerShell as well.

You can also delete the command history by using the Registry Editor. Navigate to the following key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU

Next, select RunMRU and erase all the values having a name, a letter of the alphabet in the right pane. After this, right-click on MRUList > Edit, and delete the contents of Value data.

More Command Prompt tips & tricks here.

Posted by on , in Category Windows with Tags
Ayush has been a Windows enthusiast since the day he got his first PC with Windows 98SE. He is an active Windows Insider since Day 1 and is now a Windows Insider MVP. He has been testing pre-release services on his Windows 10 PC, Lumia, and Android devices.

Leave a Reply

Your email address will not be published. Required fields are marked *


4 + 3 =