0

I'm running a batch file for building my software application. Basically it gets the latest sources, builds the project files, copies some files here and there, runs some custom tools and finally creates an installer using Installshield. For all the above actions I'm logging into a file as well. However I'm looking for something to add a little bit of customization (i.e. to have some colors for the logging messages that appears on the command prompt)

I tried to learn about adding colors on command line using this script

    @ECHO OFF
    :COLORCHANGER
    cls
    echo                   --------------------------------------------
    echo                   Background            Text
    echo                   --------------------------------------------
    echo                   0=Black               A=Bright Green
    echo                   1=Deep Blue           B=Bright Blue
    echo                   2=Dark Green          C=Light Red
    echo                   3=Blue                D=Light Purple
    echo                   4=Dark Red            E=Light Yellow
    echo                   5=Purple              F=Bright White
    echo                   6=Dark Yellow                
    echo                   7=White
    echo                   8=Grey
    echo                   9=Deep Blue
    echo                   --------------------------------------------
    set /p col=Color code: 
    Color %col%
    if not ERRORLEVEL 0 goto :showerror
    echo "Hello DOS"

    @ECHO Press any key to revert
    set /p col=Color code: 
    Color %col%
    if not ERRORLEVEL 0 goto :showerror
    echo "Hello DOS"
    goto :exit

    :showerror
    @ECHO Cannot set color 
    goto :exit

    :exit
    @ECHO Press any key to exit
@PAUSE

But this just changes the entire foreground/background color. I want something like this. Different colors for different line How do I achieve such a customization?

commandlinesample

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
this-Me
  • 2,139
  • 6
  • 43
  • 70

0 Answers0