Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there an auditable file on a Windows machine that shows the command-line history for either cmd or PowerShell? On UNIX machines I believe there is a hidden file in the home directory called .history.

share|improve this question
Note that the hidden file does not contain the current history. That's only in memory, as well. This is why history has to be a built-in command. – JdeBP Jan 31 '12 at 14:03
up vote 4 down vote accepted

For plain old cmd, no there really isn't anything like that.

Even under PowerShell, I believe the history is still limited to the lifetime of the PowerShell session, though it gives you the functionality to work with and export the history, and even load it. You can use that to create some helper scripts to load and save your history easily as demonstrated here, but nothing out-of-the-box.

share|improve this answer

After looking into this some more it looks like there isn't a physical file-system file on Windows because everything is stored in memory. It looks like I can get the history using doskey.

doskey /history

I can extract a file by simply dumping that output to a file...

doskey /history > myhistoryfile.txt
share|improve this answer
That's only the history for the current console window's lifetime, as vcsjones says above. – mfinni Jan 30 '12 at 19:52
Yep, but for regular-old "cmd" it looks like the only option. PowerShell isn't in use in this particular situation. – kdmurray Jan 30 '12 at 19:54

Your Answer


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.