How to retrieve/recover commands that I ran on windows command prompt before the last restart?

6

1

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?

Affy

Posted 2017-03-05T05:37:46.023

Reputation: 161

Question was closed 2017-03-06T16:58:04.843

1

Related: Is there a global, persistent CMD history?

– maddin45 – 2017-03-05T12:01:39.803

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 – 2017-03-06T16:59:31.677

Answers

4

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.

Herb Wolfe

Posted 2017-03-05T05:37:46.023

Reputation: 264

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 – 2017-03-05T11:08:31.093

Updated the answer to expand and clarify saving the command history. – Herb Wolfe – 2017-03-05T12:17:03.047

Downvoter care to explain what's wrong with the answer? – Herb Wolfe – 2017-03-06T12:04:07.663

3

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.

hvindin

Posted 2017-03-05T05:37:46.023

Reputation: 141

2

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.

Luke

Posted 2017-03-05T05:37:46.023

Reputation: 305