I know with linux when I want to change the color code I can type in

echo -e \033[COLORm]

Is there an easy way like this to change the color in windows scripting. I tried

@echo off
REM This program will list all the colors 
REM Selected by user input

set /p color=Enter the color you would like to use to display the sentence Hello World: 

if %color% == [Blue]
color 01 
Echo "Hello World"
Exit 0

Why can't I simply type in color followed by the code

But I had no luck, I'm still new at this. Any suggestions where I could just type in echo followed by color then code like linux.

Edited by theashman88

3 Years
Discussion Span
Last Post by cuzintone

You can, the syntax of the color command is COLOR [background][foreground]. From there you use the following table

    0 - Black
    1 - Blue
    2 - Green
    3 - Cyan (Aqua)
    4 - Red
    5 - Purple
    6 - Yellow
    7 - White
    8 - Gray
    9 - Light Blue
    A - Light Cyan (Aqua)
    B - Light Red
    C - Light Purple
    D - Light Yellow
    E - Bright White

So if you want yellow text on a blue background you type
  COLOR 16

Hope this helps.
Votes + Comments
This is correct answer. Although not accepted. It is.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.