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.

Recommended Answers

All 3 Replies

  1. Bold Text Here

        • Item One*************

        • Item Two

        • Item Three
  • *

  • *************

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.
commented: This is correct answer. Although not accepted. It is. +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.