Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6534275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:13:51+00:00 2026-05-25T10:13:51+00:00

I have a batch script that can display two or more colors of text

  • 0

I have a batch script that can display two or more colors of text on the same line in the command prompt. (below)

@echo off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
echo say the name of the colors, don't read

call :ColorText 0a "blue"
call :ColorText 0C "green"
call :ColorText 0b "red"
echo(
call :ColorText 19 "yellow"
call :ColorText 2F "black"
call :ColorText 4e "white"
pause
goto :eof

:ColorText
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
goto :eof

however that text must be entered in the script before-hand by editing the batch file with notepad. i’d like to be able to just open the command prompt and type something like:

cecho /blue hello world!

or

cecho blue "hello world!"

or something simple where i can supply the color (preferably as a string not a color code) and text (with or without quotations).


I don’t know if this is of any use to you but it is possible to save this part of the script:

echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
goto :eof

(from “:ColorText” to the end of the script)
and save it as “ColorText.bat” in “C:\windows\system32”. Then in the other half of the script, everywhere you see:

call :ColorText

Change it to:

call ColorText

(Omit the colons)
And save that script as colors.bat in “C:\windows\system32”. Then open the command prompt and type “colors”. This is how i want it to function; no additional commands, setup scripts, file paths; just a simple one or two word function with all that messy code going on in the background (out of sight). However the above idea still won’t let me specify my own text or color from the command prompt…. any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:13:52+00:00Added an answer on May 25, 2026 at 10:13 am

    EDIT: Take 3

    Create the folder C:\Utilities. Add this folder to your Path environment variable so Windows looks there for additional scripts and commands.

    1. Open Control Panel, System, Advanced System Settings (or “Advanced” in Windows XP), Environment Variables.
    2. In the “System variables” list, select the “Path” variable.
      Do not mess these next steps up!
    3. Press Edit.
    4. Place the cursor at the end of the line and make sure no text is selected.
    5. Add the text ;C:\Utilities, including the semi-colon. Do not remove any other text.
    6. Press OK.
      Breathe easy again.
    7. Press OK as many times as necessary to close all windows.

    Take the script following the :ColorText label and save it to C:\Utilities\cecho.bat. Put an @ in front of echo off to prevent echo off from appearing during the script.

    CEcho.bat

    @Echo Off
    SetLocal EnableDelayedExpansion
    For /F "tokens=1,2 delims=#" %%a In ('"Prompt #$H#$E# & Echo On & For %%b In (1) Do Rem"') Do (
    Set "DEL=%%a"
    )
    <Nul Set /p ".=%DEL%" > "%~2"
    FindStr /v /a:%1 /R "^$" "%~2" Nul
    Del "%~2" > Nul 2>&1
    EndLocal
    

    Now you can use this command from any command line or script. Usage:

    CEcho color "text"
    

    Edit: In response to your comment:

    You can use words for colours by inserting the following lines and replacing the FindStr line:

    Set Color=%1
    If %1==blue Set Color=9
    If %1==red Set Color=C
    etc...
    FindStr /v /a:%Color% /R "^$" "%~2" Nul
    

    Now you can type:

    CEcho red "apple"
    CEcho blue "water"
    CEcho A "grass"
    CEcho 6 "dirt"
    CEcho 26 "tree"
    

    Note that the color word is case sensitive.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a plain perl script that can be run from the command-line via
I have as command-line parameters to my batch script a list of filenames and
Struggling with command line again, I have figure out that I can store the
I have a batch script that calls a process and currently it waits for
I have a nightly build DOS batch script that invokes devenv.exe to build a
For some reason, we have a script that creates batch files to XCOPY our
I have a batch file that I can't change, but I want to automate
I have a batch script that checks if a registry key exists and if
I have a batch script that I want to call from an MSBuild project,
I have a batch script I run before our performance tests that does some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.