Different Colours in Batch Files

Introduction: Different Colours in Batch Files

About: I enjoy anything to do with computers. I have made some interesting scripts, and I am constantly improving my skill set. One day I hope to become a programmer, although in what category is still a mystery (al…

Everyone, with the help of g-one, I have created a function that you can install into your windows/system32 folder to get more than one colour in batch files.

Copy and paste the following code and save it as ncol.bat (this is very important that you save it exactly like that).

@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


Once that is done, head over to your windows system32 folder and save it in there (C:\Windows\System32)

Read on for instructions...


Step 1: Instructions

Ok, how to use this function.

Firstly, type it in as you would any command "ncol"

The first parameter is the text you want converted.

The second parameter is the colour (must be correspondent to the colour command).

Example:

ncol "Hello" 10

Would output:

Hello


Just try it!

Note: If you have spaces, you must use quotation marks ("").

P.S: type in "ncol /?" for more help.

Unfortunately, special characters cannot be converted yet... (~!@#$%^&*()_+=-/,.<>":;'[]\{}|`)

And there is a little glitch with it, but other than that... It's good to go!

--EDIT--
To add more colors onto one line, use the && operator. E.g: ncol "Hello " 12 && ncol "there" 23
would output "Hello " in one color, and "there" in another.

Be the First to Share

    Recommendations

    • For the Home Contest

      For the Home Contest
    • Big and Small Contest

      Big and Small Contest
    • Make It Bridge

      Make It Bridge

    26 Comments

    0
    NotePro
    NotePro

    1 year ago

    Does the file have to be named "ncol.bat" ?

    0
    wilderness tech
    wilderness tech

    6 years ago

    umm... when i do that i get

    '"Hello.@"' is not recognized as an internal or external command,
    operable program or batch file.
    FINDSTR: Cannot open *.@
    Could Not Find C:\Users\MyName\*.@

    0
    Mclover152
    Mclover152

    8 years ago on Introduction

    No its fine, i found a different program that does the same thing but works. I still like ur idea though.

    0
    Mclover152
    Mclover152

    Reply 8 years ago on Introduction

    Im making a movement simulator game in batch (Kind of like Terraria) And for every block is a character (or piece of text). I really want to save myself from writing over 300 variables. So is there a way to have arrays in batch?

    0
    Batchcc
    Batchcc

    7 years ago

    Everyone I made a version that works view it here

    https://www.instructables.com/id/Multiple-colors-in-cmd/

    0
    The Batchicle
    The Batchicle

    7 years ago

    Hey Pickle! just wanted to say thanks because your instructables have really helped me with getting into batch but just a question. Why don't you create any more instructables? it would be really nice if you had more :)

    0
    The Batchicle
    The Batchicle

    Reply 7 years ago

    but he doesn't post anymore does he? his last post was maybe 1 or 2 years ago. He used to be the person who fixed all my codes that didn't work and now i have piles of not working code

    0
    Governor Keagan
    Governor Keagan

    7 years ago

    Thanks, I've been trying to find a code for this. I'm thinking of using it in my Trivia.

    0
    lhan5
    lhan5

    7 years ago on Introduction

    You should add here the *.@ file that you have in your system32 because we need that and thats why it isnt working

    0
    Mclover152
    Mclover152

    8 years ago on Introduction

    It says the following when i type "ncol" in cmd.exe

    '".@"' is not recognized as an internal or external command,

    operable program or batch file.

    FINDSTR: Argument missing after /a

    Could not find C:\Users\****** ********\*.@

    0
    Prof. Pickle
    Prof. Pickle

    Reply 8 years ago on Introduction

    NCOL is a function, meaning that you need to put in the name (ncol) and then the arguments. Type in "ncol /?" for more information.

    0
    Prof. Pickle
    Prof. Pickle

    Reply 8 years ago on Introduction

    What exactly are you typing in? Are you still only putting in "ncol"?

    0
    Demon4511
    Demon4511

    Reply 8 years ago on Introduction

    He is most likely seeing this:

    http://imgur.com/xf0MHJo

    As am I! :(

    0
    Prof. Pickle
    Prof. Pickle

    Reply 8 years ago on Introduction

    As hard as I try, I can not recreate the issue on my computer. I don't really have any solid ideas as to why it is doing that for you and Mclover, but I will keep trying.

    0
    Prof. Pickle
    Prof. Pickle

    Reply 8 years ago on Introduction

    It worked for me on Windows 8, 7 and vista. What operating system are you using?