1

Possible Duplicate:
How to change the text color of comments line in a batch file

Hello I would like to print a message similar to : Test [OK] in green when a command works and Test [Failed] in red when a command fails

I found i could manage the DOS color by typing COLOR 0A for Black + Green and 0C for Black + Red and 07 for black and white.

Ex:

IF EXIST filename. (
COLOR 07
ECHO Test.
COLOR 0A
ECHO [OK]

) ELSE (
COLOR 07
ECHO Test.
COLOR 0C
ECHO [Failed]
)
REM: Setting the color back to default
COLOR 07

However when it reaches the line COLOR lines, it will just change the entire cmd screen in that color... Is there a way to print single strings in a different color.

Community
  • 1
  • 1
Simon Says
  • 35
  • 5
  • 1
    See http://stackoverflow.com/questions/2586012/how-to-change-the-text-color-of-comments-line-in-a-batch-file as well as http://stackoverflow.com/a/5344911/1012053 – eis Apr 26 '12 at 09:21
  • If you want to just _distinguish_ error messages via a different color mark, see [this post](http://stackoverflow.com/questions/10239610/batch-how-can-i-redirect-stderr-and-stdout-from-within-the-batch-script-itself/10261154#10261154). It is much simpler than the other method... – Aacini Apr 26 '12 at 18:29

0 Answers0