color / title - Colors and Window Title
When you have several Command Prompt windows open, it is easy to lose track of which window is running what.
Changing the text and background colors with the color command and the window title with the title command makes windows easier to tell apart. They are also handy for making the result of a batch file stand out.
color and title are built into cmd.exe. To use them from PowerShell, run them through cmd /c, as in cmd /c color 0A. The console is shared, so color and title changes are also reflected in the PowerShell window, although PowerShell settings may override the colors.
How to use the color command
Basic syntax
color [background][foreground]
Specify colors as two single-digit hexadecimal values. The first digit is the background color and the second is the text (foreground) color.
For example, to use a black background (0) with light green text (A):
color 0A
The colors of the whole screen change immediately.
Color code list
You can use the following 16 colors.
| Value | Color | Value | Color |
|---|---|---|---|
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 |
A to F can be written in uppercase or lowercase.
Some example combinations:
| Command | Appearance |
|---|---|
color 0A | Light green text on black |
color 1F | Bright white text on blue |
color 4F | Bright white text on red (good for warnings) |
color F0 | Black text on white |
Restore the original colors
Run the command without arguments to return to the colors that were in effect when cmd.exe started.
color
Running color /? displays the list of color codes and a description in the console.
Using the same value for both causes an error
If you specify the same value for the background and text colors, the text would become unreadable. The colors are not changed, and the error level is set to 1.
color 00
echo %errorlevel%
For details about error levels, see
.How to use the title command
Change the window title
title string
Running the title command changes the text in the title bar of the window to the specified string.
title Build Command Prompt
You do not need to enclose a string containing spaces in quotation marks. If you add quotation marks, they are displayed as part of the title.
title "Build"
The title is not restored when a batch file ends
A title changed with title is not restored when the batch file ends. It stays until you close the window or run title again.
If you want a different title only while a batch file is running, set the title you want again at the end of the processing.
@echo off
title Backup in progress
rem Backup processing goes here
rem Set whatever title you prefer
title Command Prompt
Give a new window a title with the start command
When you open a new Command Prompt with the start command, the first argument enclosed in quotation marks becomes the title.
start "Log Monitor" cmd /k "title Log Monitor && echo Starting monitoring"
For more about the title of start, see
When the default terminal is Windows Terminal (the default in Windows 11 22H2 and later), Command Prompt runs inside Windows Terminal. In that case, title changes the name of the tab. If suppressApplicationTitle is enabled in the profile settings, title changes from applications are ignored.
Practical examples
Turn the screen red on errors so you notice them
To make a failure stand out, combine color changes with if.
@echo off
robocopy C:\data D:\backup /E
rem robocopy fails when the exit code is 8 or higher
if errorlevel 8 (
color 4F
echo The backup failed.
) else (
color 2F
echo The backup is complete.
)
pause
color
For the exit codes of robocopy, see
if errorlevel, see .
At the end, color without arguments restores the original colors.
Make an administrator window easy to recognize
A window running as administrator looks similar to a normal one, which can lead to mistakes.
Put the following at the top of a batch file that runs as administrator, and you can tell the window apart at a glance.
@echo off
color 4F
title Running as administrator
To learn how to run as administrator, see
.When colors or titles are not applied
- Check that the values are not identical: if the background and text colors are the same, nothing changes.
- Check the number of digits: if you specify only one digit, as in
color A, only the text color changes and the background becomes black (0). Specify two digits to set the background as well. - Some output keeps its color:
colorswitches the color of the whole screen, including text already displayed. However, if a program outputs text with its own colors, those parts may not change. - The title reverts: the running program may rewrite the title itself.
Summary
- Use
color background foreground, one hexadecimal digit each - Running
colorwithout arguments restores the colors from startup - If both values are the same, the colors do not change and the error level becomes
1 title stringchanges the window title- A title changed with
titleis not restored when the batch file ends