Command history – quick access DOS commands

Anytime you are running commands on windows, you do not have to keep typing the commands. You can easily access previously typed commands by using the arrow keys.

For example, suppose you used the “cd change_to_this_directory“, command to change your current directory. You can press the up arrow key, which will retrieve this command for you, thus help you in easier navigation of the commands list.

You can access all the previously typed commands, by using the up and down arrow keys.

There are additional ways that you can utilize this history, or even delete the history. Below is a list of the ways in which you may manipulate the command history:

  • View history using DOSKEY
  • Save command history
  • Clear command prompt history

View history using DOSKEY

To list all the commands that have been entered in one session, type in the command “doskey /history” without the quotes.

Save the command history

Sometimes, you may need to save a record of all the commands that you have used in one session, into either txt, html, csv or rtf file.

To do this, type in the following command into your command prompt without the quotes:

doskey /history>CommandHistory.txt

This will save a file named CommandHistory in your current directory.

You can change the .txt extension, to either csv, html, rtf to change the format into which you wish to save to.

Clear command history

The most basic way of clearing command history, is to restart the command prompt.

If this does not clear the history, or you wish to use a different method, use the one below:

  1. Press Alt + F7 on your keyboard. (This works for both command prompt and PowerShell)
Share this