The Command Prompt program enables users to run programs, batch files, automate tasks, and even perform administrative functions along with troubleshooting issues on Windows 10. The use of cmd is also often recommended in fixing methods when facing computer and disk failures, such as the SFC command and the CHKDSK command. For users who usually use the Command Prompt, the command history feature is a plus as you can cycle between previously used commands and even log them as a .txt file in an active session.
However, the history cannot be restored if you exit Command Prompt as this feature works for the current working session only. This means that if the Command Prompt window is closed or if the PC restarts then the history is wiped out. So if you want to view the command history, please read the following methods below.
2 Methods to View Command History in Command Prompt
Method 1:View Command History With Keyboard Shortcut
If you’re in a time crunch, you can trust your keyboard to help your check Command Prompt history for the current session. Besides, it is noticed that you can only view the history if you run cmd as an administrator.
- Select Run as an administrator to open Command Prompt, and execute some commands.
- In the Command Prompt window, hold the F7 key to open the list of commands you’ve run recently.
- Scan the list and press the one you want to execute again.
- Click on Enter.
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 the 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 the F8 key again will bring another possible result from history if any. Keep pressing the F8 key again and again until the history list ends.
Method 2: Using Doskey to View Command History
In the Command Prompt window, type in the command: doskey /history and press Enter.
Method to Save Command History in a .txt File
As mentioned, the command history in Command Prompt on Windows 10 only works for the current session and you cannot access the history after you restart the computer. But you can save the command history as a TXT, HTML, CSV or RTF file before closing the window so that you can have a backup of your entered commands.
- Type cmd in the search bar. Right-click on the Command Prompt app and select Run as Administrator to proceed.
- Type the command: doskey /h > c:\cmd_history.txt and press Enter. This would log your command history from Command Prompt in a .txt file on your C drive.
- Press Win + E to open File Explorer, and you will find a text document named cmd_history in C drive.
- Click on it to open the file and view the history of all your previously executed commands logged in this file.
FAQ about Command Prompt
What’s the difference between Terminal and Command Prompt?
Both programs are command-line shells that can troubleshoot errors and manage system maintenance. However, the Command Prompt is more user-friendly and suitable for day-to-day tasks. On the other hand, Terminal has more advanced functions and allows users to run several tasks or work on multiple projects simultaneously.
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?