Color cmd command - GeeksforGeeks

28 Dec, 2020
Color is an inbuilt command found inside the Windows Command Processor (cmd.exe), that is used for changing the colors for the console’s foreground and background. By default, the console has white foreground color and black background color (07 color code). The command is generally used either to personalize the aesthetics of the console window, or the make the colors more appropriate for Dim or Dark Displays (ex. TN panels). In this article, we will learn about the color command and will also take a look at the various uses it offers.
Description of the Command :Type the command – color /? in the Command Prompt.
It sets the default console foreground and background colors.
COLOR [attr]
attr - Specifies the color attribute of console output.
Color attributes are specified by two hex digits –
First corresponds to the background.
Second corresponds to the foreground.
Using the Command :The command takes in input 2 hexadecimal digits (2nd digit optional) where the first digit corresponds to the background color and the second digit corresponds to the foreground color.
Syntax :
Color (Background)(Foreground)
If the first digit is only provided, then only the foreground color changes. Each digit can have any of the values in hexadecimal codepoint (0 – f) where each one corresponds to a unique color. The digit to color correspondence is as follows –
  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
Syntax :
Color 1F
It will produce bright White on Dark Blue. Any combination of the above set of digits could be used, except for the special case in which the foreground and the background color is the same (Ex. color FF or color 33). In that case no color change occurs, and the value of %ERRORLEVEL% changes to 1. If the command is executed without providing any parameters, then the command will restore the color to which cmd.exe initially started as.
Changing Only The Foreground Color :Syntax :Color (Hex_digit)(Hex_digit) is a digit (or character) within the hexadecimal range, i.e. it should belong in the range 0-F.Example :We will change the foreground color to Yellow (6).Before :After :It is clear from the above images that after executing the command Color 6, the color of the foreground changes from white to yellow.Changing the Color of Background And Foreground :For changing the color of the foreground and the background of the console window, the color attributes are specified by 2 of the previously mentioned hex digits.Syntax :color (Back_Hex_digit)(Fore_hex_digit)Back_Hex_digit and Fore_hex_digit are hexadecimal digits used to determine the color of the background and foreground respectively. In the following example, we will change the background color to grey (7) and foreground color to light green (a).Before :After :
Changing Only The Foreground Color :Syntax :Color (Hex_digit)(Hex_digit) is a digit (or character) within the hexadecimal range, i.e. it should belong in the range 0-F.Example :We will change the foreground color to Yellow (6).Before :After :It is clear from the above images that after executing the command Color 6, the color of the foreground changes from white to yellow.
Syntax :
Color (Hex_digit)
(Hex_digit) is a digit (or character) within the hexadecimal range, i.e. it should belong in the range 0-F.
Example :We will change the foreground color to Yellow (6).
Before :
After :
It is clear from the above images that after executing the command Color 6, the color of the foreground changes from white to yellow.
Changing the Color of Background And Foreground :For changing the color of the foreground and the background of the console window, the color attributes are specified by 2 of the previously mentioned hex digits.Syntax :color (Back_Hex_digit)(Fore_hex_digit)Back_Hex_digit and Fore_hex_digit are hexadecimal digits used to determine the color of the background and foreground respectively. In the following example, we will change the background color to grey (7) and foreground color to light green (a).Before :After :
Syntax :
color (Back_Hex_digit)(Fore_hex_digit)
Back_Hex_digit and Fore_hex_digit are hexadecimal digits used to determine the color of the background and foreground respectively. In the following example, we will change the background color to grey (7) and foreground color to light green (a).
Before :
After :
Operating Systems
Operating Systems
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Memory Management in Operating System
File Allocation Methods
Segmentation in Operating System
Difference between Internal and External fragmentation
Introduction of Process Management
Mutex lock for Linux Thread Synchronization
States of a Process in Operating Systems
Program for Least Recently Used (LRU) Page Replacement algorithm
Logical and Physical Address in Operating System
Dining Philosopher Problem Using Semaphores