I am asking if there is a quick way/command to save the current standard output from cmd.exe or powershell to a file.

For example, I have run a bunch of commands in cmd.exe which generating like hundreds of lines of standard output. Ideally, I am looking for a single command to do "select all" and save to a file automatically.

Note: I've read this. But I don't want to change my original commands, so ">" or ">>" redirection cannot be used in this scenario.


  • Which version of Windows are you using? – iglvzx Apr 13 '12 at 1:10
  • Windows 7 @iglvzx – Zeiga Apr 13 '12 at 2:57

There may be a more efficient solution, but you can get the job done with a little help from AutoHotkey.

First, compile the following script:

ClipboardBackup := Clipboard
Clipboard =

Send, !{Space} ;Menu
Sleep, 100
Send, e ;Edit
Send, s ;Select All

Send, {Enter} ;Copy

FileAppend, %Clipboard%, *

Clipboard := ClipboardBackup


Place the .exe file in a %PATH% directory. I named mine savecmd.exe.

Now, you can effectively save the contents of the command prompt window by using the following syntax:

savecmd > file.txt




Note: You can add more to the AutoHotkey script to clean up the output a bit, but it works!

  • @Zeiga, @ iglvzx, I don't get it, what's the difference between doing it this way vs simply "right-click, select all, copy, paste to file"? – Pacerier Aug 23 '15 at 21:32

Here's a more elegant solution, using PowerShell: http://technet.microsoft.com/en-us/magazine/ff687007.aspx

Start-Transcript [[-path] FilePath] [-force] [-noClobber] [-append] 

<your commands>


<get content from FilePath>
  • Please note that only link posts are discouraged. – Tamara Wijsman Apr 13 '12 at 9:47
  • The link is the answer, in this case, I'm not redirecting him to ask the same question there. And please not that not only the first answer there got votes, the second one is related exactly to my case. – user127350 Apr 13 '12 at 17:32
  • OK. I changed it, but I see it more like a way to generate content for google, than a something that should be done. I don't think that link will be broken anywhere soon, plus it offers the exact solution, it's not like there are parts of the solution scattered around. – user127350 Apr 13 '12 at 17:46
  • 2
    But does this work after-the-fact? Zeiga is looking for a solution to save the output without having to first plan for it. – iglvzx Apr 13 '12 at 18:06
  • 2
    @Radoo perhaps you should explain in some more detail why it works? – Ivo Flipse Apr 13 '12 at 19:44

Copy the contents of the cmd window and past it into Word, or other text editor. See Microsoft's documentation on how to copy text from a command prompt window.

  • Welcome on superuser. Is it usually preferred to write the essential steps from an external link instead to paste only the link because with time external resources can became unreadable, and the answer not anymore useful. Feel you free to edit your post with the link below your answer. – Hastur Jul 18 '14 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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