Multiple Colors in Cmd

3,097

6

2

Posted in TechnologyMicrosoft

Introduction: Multiple Colors in Cmd

Microsoft doesnt have a built in way to have multiple colors in a batch file at the same time this code was modified from Instrucable member Prof.+Pickle the original Instrucable can be found here

Original Code

Step 1: The Code

Here is the code
@echo off
setlocal
if "%~1"=="/?" (
echo.
echo ncol ["Text"] [Colour]
echo.
echo "Text" - The text you want displayed in another colour.
echo Remember that spaces cannot be added if you don't put the text in
echo quotation marks (""^).
echo.
echo Colour - The hexadecimal colour code that you want the text to be changed into.
echo For more information of colour codes, see "color /?"
echo.
exit /b
)
for /f "delims=#" %%i in ('"prompt #$H# &for %%b in (1) do rem"') do set "bs=%%i"
>"%~1.@" set /p "=.%bs%%bs%%bs%%bs%"findstr /p /a:%2 . "*.@"
endlocal
del "*.@"
@echo on
@exit /b

Step 2: How to Use It

To use ncol.bat call it from at batch file or Cmd using this line

ncol "Text you want colored don't forget the quotes" 04

I chose 04 which is red text and a black background the color codes can be accessed by typing

color /? into cmd

See Prof.+Pickle's other instructables Here

see my instructables Here

and see my three most popular below

Full screen batch matrix

Windows folder tricks

Get Windows Xp Free legally

See ALL my other batch tutorials Here

Share

    Recommendations

    • Microcontroller Contest

      Microcontroller Contest
    • Science of Cooking

      Science of Cooking
    • Spotless Contest

      Spotless Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    2 Comments

    how would i apply this to my own batch program?

    1 reply

    copy and paste the code into notepad save it as ncol.bat then choose where to put the file if you can place it in System32 because you are an admin then do that otherwise in the same folder that contains your batch script is where you should put it finally let's say this is your code

    @echo off

    Cls

    Echo hello in 02 and goodbye in 03

    Pause

    Edit the file to

    @echo off

    Cls

    Call ncol 02 hello && call ncol 03 goodbye

    Pause