Almost the same question was asked within 6 months after that, and jeb provided a good answer 3 after that: how to have several colors in a batch file?
His answer allows you to print multiple colors on one line!
Here is an adaptation of his solution as a stand-alone batch file that can be used as a utility for printing in color in batch mode. To print Hello world! in red text on a white background, you should use call colorText f4 "Hello world!" . See comments in the code for full documentation and limitations.
@echo off :ColorText Color String :: :: Prints String in color specified by Color. :: :: Color should be 2 hex digits :: The 1st digit specifies the background :: The 2nd digit specifies the foreground :: See COLOR /? for more help :: :: String is the text to print. All quotes will be stripped. :: The string cannot contain any of the following: * ? < > | : \ / :: Also, any trailing . or <space> will be stripped. :: :: The string is printed to the screen without issuing a <newline>, :: so multiple colors can appear on one line. To terminate the line :: without printing anything, use the ECHO( command. :: setlocal pushd %temp% for /F "tokens=1 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( <nul set/p"=%%a" >"%~2" ) findstr /v /a:%1 /R "^$" "%~2" nul del "%~2" > nul 2>&1 popd exit /b
dbenham
source share