Category Archives: Uncategorized

Simple coloured output from CMD.EXE

It’s stupid to have to post this, but it’s even more stupid that the function isn’t built in.

Suggestions on the glorious Internet are just nasty: use PowerShell or use hacks around other built-in functions.

Instead, I’ve thrown together a 10KB C++ console app that starts and exits almost instantly.

To use it, you simply pipe what you want to display to the executable. You pass in one or two heaxdecimal digits as a parameter and that colours the output accordingly:

screenshot_colourecho

You can use the colour values in the wincon.h header file. These are fairly limited, so you may be best off trying the various values. The first value is the background and the second is the foreground. Not all values are supported for the background.

 

The code and executable are available here:

https://app.box.com/s/nnyv082efsiedhl2rrxw0qs761jm9t1w

 

 

Advertisements