16

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.

3 Answers 3

24

You can use the doskey command to do this:

doskey /HISTORY > history.txt
12
  • doskey is not a command, it is external utility. Commented Sep 29, 2010 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
    Commented Sep 29, 2010 at 12:32
  • seems i need to include the doskey bit?
    – Kirt
    Commented Sep 29, 2010 at 12:37
  • also, is there a way i can get it to include information printed to the screen as well?
    – Kirt
    Commented Sep 29, 2010 at 12:37
  • To see it on the screen, use just doskey /history
    – heavyd
    Commented Sep 29, 2010 at 12:43
0

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.

-1

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.

1
  • 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
    Commented Feb 18, 2017 at 23:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .