How do I export the history from the Windows command line to a text file?

I think you can do it in Linux as something like "history >filename.txt", but how do you do it in Windows? I'm a geneticist, and I want a record of exactly what programs I've run for my lab book.

I'm using Windows 7 64 bit if it makes a difference.


You can use the doskey command to do this:

doskey /HISTORY > history.txt
  • doskey is not a command, it is external utility. – Andrejs Cainikovs Sep 29 '10 at 12:29
  • 1
    @Andrejs, actually its built into cmd.exe. See the Wikipedia article: In current Windows NT-based operating systems DOSKey's functionality is built into cmd.exe, although the DOSKey command is still used to change its operation. – heavyd Sep 29 '10 at 12:32
  • seems i need to include the doskey bit? – Kirt Sep 29 '10 at 12:37
  • also, is there a way i can get it to include information printed to the screen as well? – Kirt Sep 29 '10 at 12:37
  • To see it on the screen, use just doskey /history – heavyd Sep 29 '10 at 12:43

clink provides features that are similar to GNU readline and bash. In addition to history, you get something that's very similar to the navigational power that you get in Unix.


To export the history, I was able to simply right click the window, click "select all" then CTRL-C to copy. I then CTRL-P pasted into a text editor.

You'll want to max out the screen buffer height to 9999 when you start your session because you'll only be able to copy text that's showing in the buffer. You set the screen buffer height by right clicking the title bar of the cmd window, select properties, click the layout tab.

  • Please read the question again carefully. Your answer does not answer the original question. OP want's to copy the command history not the command output (screen contents) – DavidPostill Feb 18 '17 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.