Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Sometimes I forget how the exact syntax of a CMD command looks and then I would like to search my own CMD history. Clearly, within the same session, you can browse it with the up and down arrow keys but what about the history of former CMD sessions? Is there a file, a log the history gets written to or does it all go to digital Nirvana?

Thanks!

share|improve this question
add comment

6 Answers

No, Windows command prompt history can't be saved when a session ends.

share|improve this answer
    
for real? how do you know this? Sorry for questioning you, I guess you are right but how can u know unless u programmed the damn thing ;) –  raoulsson Dec 18 '09 at 0:08
    
Ok, let me rephrase :-) The Windows command interpreter ("cmd.exe") doesn't provide any support for saving/exporting/keeping history, of, if it does, Microsoft didn't document it and nobody was ever able to find it. You can of course try to work around that, like Sean suggested, but there's (or does appear to be) no built-in support for this. –  Massimo Dec 18 '09 at 6:17
1  
You can press F7 to see a history list of the current session. –  jftuga Feb 14 '11 at 13:20
add comment

Not natively but check out: http://mridgers.github.io/clink/ , makes cmd.exe much more productive. Quoting features from the project page:

Powerful Bash-like line editing from GNU's Readline library.
Superior path completion (TAB).
Paste from clipboard (Ctrl-V).
Support for the completion of executables/commands, and environment variables.
Undo/Redo (Ctrl-_ or Ctrl-X, Ctrl-U)
Improved command line history.
Persists across sessions.
Searchable (Ctrl-R and Ctrl-S).
History expansion (e.g. !!, !<string>, and !$).
Scriptable completion using Lua.
share|improve this answer
add comment

Massimo is correct that your command prompt history does not persist across sessions. You could manually grab this before closing your prompt by typing doskey /history > history.txt

Or... you could use PowerShell as your CMD prompt, and follow this post to persist your history across sessions.

share|improve this answer
add comment

Command History: To enable a command history (that can be accessed using the up and down arrow keys) just execute doskey at the command prompt. For example, to create a command history of 100 elements:

doskey /listsize=100

ref:https://users.cs.jmu.edu/bernstdh/web/common/help/ntshell.php

share|improve this answer
2  
That doesn't answer the question at all?? –  Chopper3 Feb 14 '11 at 13:27
add comment

It is possible to save the current history to file,

`$ doskey /history > somefile.txt`

But it seems there is no way to load it back as history. It is possible only to use a command line argument to load and execute all lines,

cmd.exe /K somefile.txt

, what can be useful to load a list of doskey macros. This invocation could be included in a shortcut so you don't need to type it everytime; this reference has some additional info on this approach.

There is a similar question on Superuser that bring some alternatives, including clink, as suggested by @RobertBak.

share|improve this answer
add comment

This can also be useful: https://code.google.com/p/clink/ It is opensource and very fast AND: it has built-in history!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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