How to quickly save what is currently shown in cmd.exe to a file

Solution 1:

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
ClipWait

FileAppend, %Clipboard%, *

Clipboard := ClipboardBackup

ExitApp

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

Demonstration:

save

verify

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

Solution 2:

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>

Stop-Transcript

<get content from FilePath>

Solution 3:

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.