I was debugging an issue via command prompt and was trying many scripts/commands and somehow one of them worked. So in excitement, I restarted my machine.

Now I don't really remember which command did actually worked for me. How do I recover all the commands that I ran before the restart? Is there any way to find out that in Windows 10?

  • 1
    Related: Is there a global, persistent CMD history? – maddin45 Mar 5 '17 at 12:01
  • ok, I misunderstood your question. You want the commands that you run in the last session before a reboot. use clink, it keeps history of all files. this is the correct answer, as written in the duplicate link. – magicandre1981 Mar 6 '17 at 16:59

You can't. Windows cmd doesn't have an option to save the command history to a file, that can be used across sessions, like bash or other unix shells do.

  • 4
    @magicandre1981 It's partially correct. Cmd history does not persist across restarts so "You can't" is a correct answer to the OPs actual question. – DavidPostill Mar 5 '17 at 11:08
  • Updated the answer to expand and clarify saving the command history. – Herb Mar 5 '17 at 12:17
  • Downvoter care to explain what's wrong with the answer? – Herb Mar 6 '17 at 12:04

It depends if it was just a Command Prompt window or actually a PowerShell window. If it was PowerShell and you are running version 5 (latest) then you are in luck. Just press the Up button in the prompt.

Alternatively, if this isn't the case, then for future reference you could have a look at this post about saving history:

PowerShell v5 includes command history

Essentially PS5 implements what used to be a third party add-on. So if you aren't running PS5 you can still install it so this doesn't happen to you again.


What is essential in your question is that you want to see what you typed AFTER you restarted the computer.

Thus, there is no logging for commands launched in a CMD prompt.

On the other hand, there are PowerShell​ logs, but you must have configured them before.


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