Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ANSI Colors in standard Windows 10 shell
@echo off
cls
echo  STYLES 
echo ^<ESC^>[0m Reset
echo ^<ESC^>[1m Bold
echo ^<ESC^>[4m Underline
echo ^<ESC^>[7m Inverse
echo.
echo  NORMAL FOREGROUND COLORS 
echo ^<ESC^>[30m Black (black)
echo ^<ESC^>[31m Red
echo ^<ESC^>[32m Green
echo ^<ESC^>[33m Yellow
echo ^<ESC^>[34m Blue
echo ^<ESC^>[35m Magenta
echo ^<ESC^>[36m Cyan
echo ^<ESC^>[37m White
echo.
echo  NORMAL BACKGROUND COLORS 
echo ^<ESC^>[40m Black
echo ^<ESC^>[41m Red
echo ^<ESC^>[42m Green
echo ^<ESC^>[43m Yellow
echo ^<ESC^>[44m Blue
echo ^<ESC^>[45m Magenta
echo ^<ESC^>[46m Cyan
echo ^<ESC^>[47m White (white)
echo.
echo  STRONG FOREGROUND COLORS 
echo ^<ESC^>[90m White
echo ^<ESC^>[91m Red
echo ^<ESC^>[92m Green
echo ^<ESC^>[93m Yellow
echo ^<ESC^>[94m Blue
echo ^<ESC^>[95m Magenta
echo ^<ESC^>[96m Cyan
echo ^<ESC^>[97m White
echo.
echo  STRONG BACKGROUND COLORS 
echo ^<ESC^>[100m Black
echo ^<ESC^>[101m Red
echo ^<ESC^>[102m Green
echo ^<ESC^>[103m Yellow
echo ^<ESC^>[104m Blue
echo ^<ESC^>[105m Magenta
echo ^<ESC^>[106m Cyan
echo ^<ESC^>[107m White
echo.
echo  COMBINATIONS 
echo ^<ESC^>[31m red foreground color
echo ^<ESC^>[7m inverse foreground ^<-^> background
echo ^<ESC^>[7;31m inverse red foreground color
echo ^<ESC^>[7m and nested ^<ESC^>[31m before nested
echo ^<ESC^>[31m and nested ^<ESC^>[7m before nested
@mlocati

This comment has been minimized.

Copy link
Owner Author

commented Jun 15, 2016

Output:

output

PS: Download the raw file: it contains the escape character (hex 1B, dec 27, oct 33).

@Tymski

This comment has been minimized.

Copy link

commented Jul 16, 2017

Cool

@rourke

This comment has been minimized.

Copy link

commented Dec 13, 2017

@mlocati Thanks for this! However it doesn't work in a for loop:

image

Do you know how to solve this?

@AndyK70

This comment has been minimized.

Copy link

commented Jan 9, 2018

@rourke it works in a loop, try
grafik

But if you put in timeout it works only for the first loop pass. Maybe there is something about this command which breaks the coloring codes:
grafik

If you go with pause it works:
grafik

if you only want the time delay but no user interaction you should go with the oldstyle ping:
grafik

@MG-Tech

This comment has been minimized.

@xuanchuong

This comment has been minimized.

Copy link

commented Dec 28, 2018

very nice (y)

@T0MuX

This comment has been minimized.

Copy link

commented Feb 1, 2019

Not working for me too. Win7 SP1 NT6.1.7601.
I type directly thoses commands in cmd.exe it even no copying right.

@ACBob

This comment has been minimized.

Copy link

commented Mar 20, 2019

Thank you for this.
Now it's easier for me to identify my error codes!

@hXR16F

This comment has been minimized.

Copy link

commented May 21, 2019

Very helpful
Screenshot_1

@ghost

This comment has been minimized.

Copy link

commented Jul 10, 2019

@MG-Tech @T0MuX This is for Windows 10 (Build 16257 and higher)

@tuanla07

This comment has been minimized.

Copy link

commented Aug 24, 2019

@MG-Tech @T0MuX This is for Windows 10 (Build 16257 and higher)

How can we try it with Win7 & WinXP?

@mlocati

This comment has been minimized.

Copy link
Owner Author

commented Aug 24, 2019

How can we try it with Win7 & WinXP?

@tuanla07 those versions of Windows don't support this feature

@hXR16F

This comment has been minimized.

Copy link

commented Sep 2, 2019

@tuanla07 By using ansicon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.