I want to cut and paste from cmd and keep the color information when pasting to another application. It's similar to pasting in most applications with formatting information.

Is there a way to do this? Or can it be done with an app similar to cmd?

alt text

5 Answers 5


The PowerShell folks, on their blog, posted an article titled: Colorized capture of console screen in HTML and RTF

Once it's in a RTF file, with colors, open the RTF with Word or OpenOffice and copy the text to your target application.

As PowerShell is a nice replacement of cmd.exe with a lot more features, give it a try.

  • 3
    It's not so much a replacement as an alternative. Compatibility dictates that it can't replace cmd :-)
    – Joey
    Dec 2, 2009 at 14:54
  • 1
    Yes, you're right, Johannes! "Danke schön" for the clarification :-) .
    – Snark
    Dec 2, 2009 at 15:00
  • +Awesome! Thanks. It was a bit confusing at first since I had never used PowerShell, but it worked exactly as described. Dec 3, 2009 at 11:08
  • There is a Gist with the code: gist.github.com/LeoColomb/1a683e7a05da067259e9
    – dualed
    Oct 25, 2018 at 11:41
  • The link is broken. Jul 6, 2019 at 16:46

Windows Terminal can be handy with its copyFormatting setting (https://docs.microsoft.com/en-us/windows/terminal/customize-settings/interaction).


Snark's answer is useful, but the link is broken. The updated link to the MSDN blog post is here: Colorized capture of console screen in HTML and RTF

You need to copy the functions from the blog post and then paste them into PowerShell. And then you can run commands like:

$htmlFileName = "$env:temp\ConsoleBuffer.html"
.\Get-ConsoleAsHtml | out-file $htmlFileName -encoding UTF8


Colours in cmd are not the same as normal colours, it's the interpreter interpreting colour codes. I do not believe it's possible to do, and checking in Console2, it can't do it either, so it's probably for a very good reason.

  • AFAIK, Windows Console doesn't support ANSI colour codes (as Unix terminal emulators do); the program must call special functions to set the text colour. Also, a program can read the complete contents of its screen buffer (that's how that PowerShell snippet works) -- and it would be possible to make Console2 remember everything too. There's no real reason preventing it. Dec 2, 2009 at 13:53
  • Well, I'm often wrong ;) I assumed the two would work similarly, as cygwin's tools have working colour, but they must have implemented that themselves.
    – Phoshi
    Dec 2, 2009 at 16:16
  • @grawity looks like ansi is supported natively in windows console in windows 10 msdn.microsoft.com/en-us/library/windows/desktop/… Nov 14, 2016 at 5:43

There is a long winded way of doing it, using screen capture?

  1. Hit Alt+PrtScr
  2. This will copy the window to the clipboard
  3. From Start, enter mspaint
  4. Click on Edit/Paste or Ctrl-V to paste the contents of clipboard
  5. Edit it to only show the command box and save it to PNG (GIF will lead to Paint dithering the classic grey text, and JPEG would create artefacts around your text).

Then those screen capture shots, will be ready to be inserted into Word as an image for documenting purposes. Of course, it's not text, so it won't be selectable. But it may be better than nothing.

  • 2
    The only thing this workaround is missing would be running OCR against the output image :) Overkill? Possibly, but probably easier to deal with than the accepted answer. Feb 14, 2019 at 21:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .