How do I export the history from the Windows command line to a text file? You can use the doskey command to do this: doskey /HISTORY > history.txt