How to View Command Prompt (CMD) History on Windows
Knowing how to view the Command Prompt history on Windows can be highly beneficial when you’re trying to recall previous commands you’ve entered. The Command Prompt, also known as CMD, stores a history of commands that are entered during an active session. This guide will explain how to access this history.
1. Using the Arrow Keys:
The simplest method to view your CMD history is by using the arrow keys on your keyboard.
– Open CMD by typing `cmd` in the Run dialog (Win + R) or start menu search bar.
– Once the Command Prompt window is open, simply press the Up Arrow key (↑) to scroll through your most recent commands.
– Press the Down Arrow key (↓) if you want to navigate back down through the history.
This method cycles through commands entered during the current CMD session.
2. Using the DOSKEY Utility:
Another way to check command history is with the use of a program called DOSKEY that comes pre-installed in Windows.
– While in CMD, type `doskey /history` and press Enter.
– You’ll see a list of previously entered commands for that session.
Note that once you close the Command Prompt window, this history gets cleared and won’t be accessible in a new CMD session.
3. Creating A Permanent History:
If you’d like to keep a log of all your commands across sessions:
– Right-click on the title bar of your Command Prompt window and select “Properties.”
– In the Options tab, enable “Command History,” setting the buffer size you prefer.
– Another alternative is to write a script using DOSKEY in a batch file to save your command history onto a text file upon exiting CMD.
Here’s a simple script example:
“`batch
@echo off
if “%1″==”” goto end
doskey /history > %1
:end
exit
“`
Save this as `savehistory.bat` and run it when closing CMD by typing `savehistory yourfilename.txt`.
4. Accessing CMD History Between Sessions Using Clink:
Clink is a third-party tool that extends the capabilities of Windows’ built-in command line interpreters.
– Download and install Clink from its official repository.
– Once installed, it automatically integrates with the Command Prompt, enhancing it with features like persistent command history between sessions.
Remember that third-party tools may pose security and privacy risks; only download software from trusted sources.
In conclusion, accessing command prompt history is fairly straightforward and there are methods available whether you want real-time access for your current working session or persistence across multiple sessions.