Changing Windows Console Colours

I’ve always found it useful to have the Windows prompt (console, terminal or DOS Prompt) window showing in different colours. Rather than the boring white text on black background, I find it useful to have different windows running different colour combinations – this helps a lot when doing different things in different windows. Visually knowing that a script is running in the red window or the green window, etc. quickly helps to find the right window and saves a couple of seconds each time on.

Manually – from the GUI

Once you start the command prompt, you can click on the top-left to bring up the menu and select either “Defaults” or “Properties”. Changing “Properties” will change it for the current window while changing “Defaults” will change it for the shortcut/ command that started this window. So, every time you start the command prompt the same way, it will give you the updated colours.

Clicking on either of the two brings up the settings – navigate to the ‘Colors’ part and you’ll see the screen below to adjust the colours of the window.

Manually – the color command

The color command on Windows is basically what we need to use. Bring up the help for the command shows us this.

E:\blog>color /?
Sets the default console foreground and background colors.

COLOR [attr]

  attr        Specifies color attribute of console output

Color attributes are specified by TWO hex digits -- the first
corresponds to the background; the second the foreground.  Each digit
can be any of the following values:

    0 = Black       8 = Gray
    1 = Blue        9 = Light Blue
    2 = Green       A = Light Green
    3 = Aqua        B = Light Aqua
    4 = Red         C = Light Red
    5 = Purple      D = Light Purple
    6 = Yellow      E = Light Yellow
    7 = White       F = Bright White

If no argument is given, this command restores the color to what it was
when CMD.EXE started.  This value either comes from the current console
window, the /T command line switch or from the DefaultColor registry

The COLOR command sets ERRORLEVEL to 1 if an attempt is made to execute
the COLOR command with a foreground and background color that are the

Example: "COLOR fc" produces light red on bright white

So, that’s what we need to do to change the colour from the command line – the example below changes the colour to white text on a green background.

E:\blog>color 2f

Changing colours when launching cmd.exe

Starting cmd.exe with a /T switch followed by the colour combination will start the command window with the colours as you want. So, if you did cmd.exe /T:2f, it would start a command window with the colours set to white text on a green background.

So, one way to set up for different colours in different command prompt windows. One way could be to have different shortcuts that either have different settings configured either through:

  • Adjusting the defaults after starting the command prompt from that shortcut
  • Adjusting the command link properties and adding the /T parameter

My Setup – CMD files

Remembering and doing this as required on the command line is easy to do, but I do find it a bit tough to remember the colour combinations and picking them. So, what I’ve done is created different command files that have just the single colour comination line in it.

So, in my case, I have:

  • green.cmd has just color 2f in it
  • blue.cmd has color 1f
  • black.cmd has color 0f
  • black-old.cmd has color 0A
  • white.cmd has color f1

Then, I put these into a directory on my Windows path so that now, in my command window, I can just do:


…and it will change the console to the white text on a green background. Then, white.cmd changes it to blue text on a white background.

Putting this to Use

There are a few ways to make this work for us:

  • The main use for me is to use different command windows with different colours to visually differentiate windows that are doing different things.
  • We can also code in color commands into CMD files to change the colurs of command windows as scripts/ programs run. For example, we have some tools that are orchestrated through CMD files. Adding color commands into the script as it passes through stages allows us to visually update the status.

A word of caution

Some scripts and command line programs output coloured text to the console – this may not always work so well if their assumptions of the basic colours are not met due to us changing the colours on our own.

comments powered by Disqus