Programming Field

Color - DOS/Command Prompt Reference

[Windows NT series] Changes current prompt's display color.

Syntax

color [<attribute>]
<attribute>

Specifies two characters in order of background color and foreground (text) color. The character to be used is as followings. (case insensitive)

CharacterColorCharacterColor
0Black8Gray
1Blue9Light blue
2GreenALight green
3Aqua (lighter than light blue)BLight aqua
4RedCLight red
5PurpleDLight purple
6Dark yellowEYellow
7White (light grey)FBright white

If omitting <attribute> (simply type ‘color’), the default setting is used.

Details

Usage of Color

This command is used for changing the prompt color. When changing the color, the color of the text that was previously output will also be changed. To change the default prompt setting, use /T option of Cmd, open Command Prompt property (‘Properties’ in window menu), or change Registry DefaultColor setting (in HKEY_CURRENT_USER\Software\Microsoft\Command Processor).

Note that if specifying same character in two characters (i.e. same color for background and foreground), the command will fail and set Errorlevel value to 1.

This command cannot be used for changing the color temporarily.

[MS-DOS, Windows 95/98/Me, Windows 10 or later] To change the color temporarily in batch files, it is necessary to print Escape Sequence for changing the color directly by using Echo command. For example, the following code will change ‘Hello’ part only to red color.

echo Hello, world

(Example of editing in VSCode)

echo Hello, world (Example of editing in VSCode)

* In the above code example (not the image), there is an escape character ‘’ (character code 0x1B) just before ‘[’ character. Some browser might not display its character, but you can use the character by copying entire text.
* We won't cover escape sequences here. For more details, please search online such for ‘escape sequence color change’.

See also