Change the DOS Prompt Color in a Batch File

The COLOR command changes the colors of the DOS prompt text and (optional) background. COLOR takes a one or two-character argument. With one character, you can specify the text color. With two characters, the first character specifies the color of the background, and the second character the text color. The characters and colors are as follows:

0 = Black

1 = Blue

2 = Green

3 = Aqua

4 = Red

5 = Purple

6 = Yellow

7 = White

8 = Gray

9 = Light Blue

A = Light Green

B = Light Aqua

C = Light Red

D = Light Purple

E = Light Yellow

F = Bright White

For example, if your batch file needs to report an error condition, consider making the command prompt background red, and show the text in bright white. The following does the trick:

COLOR 4f

Note that you are not allowed to set the foreground and background colors the same. Trying to do so will cause the COLOR command to ignore your parameters. From within a batch file, the ERRORLEVEL will be set to 1.

To reset the colors to the default, just enter the COLOR command without any parameters.

Other Resources