You can be more quicker while in Command Prompt using the command history feature, no need to type same long commands again and again and in this guide, i'll show you how to use it.
How to use command history of Command Prompt in Windows 10
If you're a frequent user of the Windows 10 Command Prompt and use it more then GUI, the command history feature allows you to view and quickly reuse recent command instead of having to retype them again and again, making your daily tasks more quicker and efficient.
In this Windows 10 guide, we'll walk you through the steps to access your command history and export your recently typed command to a external file while using Command Prompt.
#1How to view Command Prompt history with F7
To use the F7 key to view your Command Prompt history, use following steps:
1. Open Start.
2. Search for Command Prompt, and click the top result to open the console.
3. Press the F7 key.
F7 key will open the graphical interface with a list of commands you typed in the current session, even if you mistyped or correct as you can see in image.
While in the command history prompt, you can use the up or down arrow keys to select the command that you want to reuse. If you want to exit without running any command, press the Esc key.
How to view Command Prompt history with doskey
On Command Prompt, the doskey is a command line tool that recalls previously typed commandsin CMD, edits command lines, and you can use it to create macros.
In this case, you can use the command to view a list of the command history from the current session. Use these steps to find out:
1. Open Start.
2. Search for Command Prompt, and click the top result to open the console. You need to run as Administrator or set PATH else you will get a command not found error.
3. Type the following command to view the command history and press Enter:
The only problem with this tool is that you can view your current history, but you can't select the command like using the F7 key. However, you can use the arrows and pages keys on the keyboard to cycle and run previously typed commands.
1. Down arrow : Re-enters the next command that you typed. If you hit the arrow key repeatedly, it'll scroll down through the command history currently in memory.
2. Up arrow : Re-enters up the previous command that you typed. If you hit the arrow key repeatedly, it'll scroll up through the command history currently in memory.
3. Page Down : Re-enters the last command from the current session history.
4. Page Up : Re-enters up the first command from the current session history.
5. Esc : Deletes the current content of the console line.
How to export Command Prompt history to file
Unlike the Linux console, command history is only available for the current session no command from any of previous one. If you close Command Prompt, it will also clear the history, but you can use the doskey command to save the history of the commands you typed to a file.
To export your command history, use these steps:
1. Open Start.
3. Search for Command Prompt, right-click the top result, and click the Run as administrator option.
4. Type the following command to save the command history and press Enter:
doskey /h > c:\history.txt
5. View saved file.
In the command, change the c:\history.txt for the path and name of the file you want to use to export the current history. Once you've completed the steps, the Command Prompt history will be saved on the location you specified.
We're focusing this guide on Windows 10, but command history for Command Prompt has been around for years, which means that you can also use this feature on Windows 8.1, Windows 7, and previous versions.