View, save, clear Command Prompt command History
We will cover the following topics:
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- 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. Read: How to clear CMD screen?
2] View CMD history using the F7 key
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,
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 also 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: 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.