## Copy all previous cmd output and write into a file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
BoQsc
Posts: 80
Joined: 30 Jun 2014 04:10

### Copy all previous cmd output and write into a file

Code: Select all

Microsoft Windows [Version 10.0.18362.720]

C:\Users\user>


Let's say I want to output all this to a file. How can I achieve this?
Later on I'm considering parsing the cmd output for what happened and what commands and arguments were issued in the command prompt.

BoQsc
Posts: 80
Joined: 30 Jun 2014 04:10

### Re: Copy all previous cmd output and write into a file

I found something, this command shows the history of commands pasted into the command line.

Code: Select all

doskey /history
Might be enough for what I need.

BoQsc
Posts: 80
Joined: 30 Jun 2014 04:10

### Re: Copy all previous cmd output and write into a file

Code: Select all

FOR /F %a IN ('doskey /history') DO echo %a
I pasted this command into Command Prompt and there is no output. How come? I expected it to print every line.

PS. doskey /history shows the output when it is not inside FOR Loop

trelf
Posts: 1
Joined: 12 Mar 2020 08:46

### Re: Copy all previous cmd output and write into a file

So, ultimately, what you want is called redirection. To take a command's output, and create a file w/ it, you'd use:

Code: Select all

command > path:\to\filename.ext

Example:

Code: Select all

doskey /history > output.txt
That will redirect all of doskey /history's output to output.txt in the current working dir. Now, you also mentioned something about processing the text file afterward. May I ask what it is you'd like to accomplish as a whole?