color / title - Colors and Window Title

Maintained on

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.

Internal commands of cmd.exe

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

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):

Light_green_text_on_black
color 0A

The colors of the whole screen change immediately.

Color code list

You can use the following 16 colors.

ValueColorValueColor
0Black8Gray
1Blue9Light Blue
2GreenALight Green
3AquaBLight Aqua
4RedCLight Red
5PurpleDLight Purple
6YellowELight Yellow
7WhiteFBright White

A to F can be written in uppercase or lowercase.

Some example combinations:

CommandAppearance
color 0ALight green text on black
color 1FBright white text on blue
color 4FBright white text on red (good for warnings)
color F0Black 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.

Restore_colors
color
You can also see the list with 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.

Check_the_error_level
color 00
echo %errorlevel%
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>echo %errorlevel%
1
C:\users\user>

For details about error levels, see

.

How to use the title command

Change the window title

Syntax
title string

Running the title command changes the text in the title bar of the window to the specified string.

Change_the_title
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.

Quotes_become_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.

Open_a_new_window_with_a_title
start "Log Monitor" cmd /k "title Log Monitor && echo Starting monitoring"

For more about the title of start, see

.

In Windows Terminal, the tab name changes

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

. For 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: color switches 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 color without arguments restores the colors from startup
  • If both values are the same, the colors do not change and the error level becomes 1
  • title string changes the window title
  • A title changed with title is not restored when the batch file ends

Practice questions

Practice Problem

Which command gives a blue background with bright white text?

Choose one answer.

  1. color F1
  2. color 1F
  3. color 11

Practice Problem

How do you restore the colors changed with color to the ones in effect when Command Prompt started?

Choose one answer.

  1. color 07
  2. color (run without arguments)
  3. title
#Command Prompt #Batch File #Command Line #Command #color #title #Colors #Window Title