Search notes:

cmd.exe: colored output with echo

In Windows 10, it is possible to write colored output using the echo command. This is demonstrated with the following simple batch file:
@ echo off

rem
rem  Forground colors
rem

echo  Black (dark)
echo  Red (dark)
echo  Green (dark)
echo  Yellow (dark)
echo  Blue (dark)
echo  Magenta (dark)
echo  Cyan (dark)
echo  White (dark)

echo  Black (light)
echo  Red (light)
echo  Green (light)
echo  Yellow (light)
echo  Blue (light)
echo  Magenta (light)
echo  Cyan (light)
echo  White (light)

rem
rem  Background colors
rem

echo  Black (dark)
echo  Red (dark)
echo  Green (dark)
echo  Yellow (dark)
echo  Blue (dark)
echo  Magenta (dark)
echo  Cyan (dark)
echo  White (dark)

echo  Black (light)
echo  Red (light)
echo  Green (light)
echo  Yellow (light)
echo  Blue (light)
echo  Magenta (light)
echo  Cyan (light)
echo  White (light)

rem
rem   Reset:
rem
echo 

echo  Bold      
echo.
echo  Underline 
echo.
echo  Inverse   
Github repository about-cmd.exe, path: /commands/echo/colored-output.bat
The script, when run on a black background, prints

See also

The same thing does not seem possible in VBScript.
Virtual Terminal Sequences on Windows
ANSI escape sequences

Index