history in windows cmd code example

Example 1: windows history command

Use doskey! First you have to first create a storage file in a directory as:
doskey /h > c:\cmd_history.txt
Then just call your command history:
doskey /history

Optionally you can filter your history commands searching with findstr:
doskey /history | findstr "substring"

Example 2: command line history search

Ctrl+R
 - Start typing a command and the most recent matching command will appear
 - Press Ctrl+R again to cycle through results
 - Press Enter or Tab to select the result

Tags:

Misc Example