colorcolor

更改当前会话的命令提示符窗口中的前景色和背景色。Changes the foreground and background colors in the Command Prompt window for the current session. 如果在没有参数的情况下使用,则 color 会还原默认的 "命令提示符" 窗口前景色和背景色。If used without parameters, color restores the default Command Prompt window foreground and background colors.

语法Syntax

color [[<b>]<f>]

参数Parameters

参数Parameter 说明Description
<b> 指定背景色。Specifies the background color.
<f> 指定前景色。Specifies the foreground color.
/?/? 在命令提示符下显示帮助。Displays help at the command prompt.

其中:Where:

下表列出了可用作和的值的有效十六进制数字 <b> <f>The following table lists valid hexadecimal digits that you can use as the values for <b> and <f>:

“值”Value 颜色Color
00 黑色Black
11 蓝色Blue
22 绿色Green
33 AquaAqua
44 RedRed
55 紫色Purple
66 YellowYellow
77 白色White
88 灰色Gray
99 浅蓝色Light blue
aa 浅绿Light green
bb 浅浅绿色Light aqua
cc 浅红色Light red
dd 浅紫色Light purple
ee 浅黄色Light yellow
Ff 亮白色Bright white

备注Remarks

  • 不要在和之间使用空格字符 <b> <f>Don't use space characters between <b> and <f>.

  • 如果只指定一个十六进制数字,则将使用相应的颜色作为前景色,并将背景色设置为默认颜色。If you specify only one hexadecimal digit, the corresponding color is used as the foreground color and the background color is set to the default color.

  • 若要设置默认的 "命令提示符" 窗口颜色,请选择 " 命令提示符 " 窗口的左上角,选择 " 默认值",选择 " 颜色 " 选项卡,然后选择要用于 屏幕文本屏幕背景的颜色。To set the default Command Prompt window color, select the upper-left corner of the Command Prompt window, select Defaults, select the Colors tab, and then select the colors that you want to use for the Screen Text and Screen Background.

  • 如果 <b><f> 是相同的颜色值,则将 ERRORLEVEL 设置为 1 ,并且不会对前景或背景色进行任何更改。If <b> and <f> are the same color value, the ERRORLEVEL is set to 1, and no change is made to either the foreground or the background color.

示例Examples

若要将 "命令提示符" 窗口的背景色更改为灰色,将前景色更改为红色,请键入:To change the Command Prompt window background color to gray and the foreground color to red, type:

color 84

若要将 "命令提示符" 窗口前景色更改为浅黄色,请键入:To change the Command Prompt window foreground color to light yellow, type:

color e

备注

在此示例中,背景设置为默认颜色,因为只指定了一个十六进制数字。In this example, the background is set to the default color because only one hexadecimal digit is specified.

其他参考Additional References