The story Since I like to be dinosaur. [@BAU] [I HATE PS ] I would like to share this nice version of Color Batch file without too much complicate PS Code. Basic Clean text + %<% + FOREGROUND / BACKGROUND / STYLES + Some text + %>% + Clean text Combine FOREGROUND / BACKGROUND / STYLES Example: %FF_Black% + %BB_Cyan% + %Inverse% Must Convert into :: %FF_Black:m=;%%BB_Cyan:m=;%%Inverse% The rule, The last VAR doesn't change, Only the others before him. By replace %VAR% with %VAR:m=;% Code https://pastebin.com/tCn7JLGJ Open pastebin Link, Click on download. Don't copy / paste to notepad, It will fail, because ESC char Code: @echo off rem ANSI Colors in standard Windows 10 shell rem https://gist.github.com/mlocati/fdabcaeb8071d5c75a2d51712db24011 :: BASIC CHARS :: ALT 0,2,7 --> � :: WORK WITH NOTEPAD++ set "<=�[" set ">=�[0m" :: STYLES set "Reset=0m" & set "Bold=1m" set "Underline=4m" & set "Inverse=7m" :: BACKGROUND COLORS set "B_Black=30m" & set "B_Red=31m" & set "B_Green=32m" set "B_Yellow=33m" & set "B_Blue=34m" & set "B_Magenta=35m" set "B_Cyan=36m" & set "B_White=37m" set "BB_Black=90m" & set "BB_Red=91m" & set "BB_Green=92m" set "BB_Yellow=93m" & set "BB_Blue=94m" & set "BB_Magenta=95m" set "BB_Cyan=96m" & set "BB_White=97m" :: FOREGROUND COLORS set "F_Black=40m" & set "F_Red=41m" & set "F_Green=42m" set "F_Yellow=43m" & set "F_Blue=44m" & set "F_Magenta=45m" set "F_Cyan=46m" & set "F_White=47m" set "FF_Black=100m" & set "FF_Red=101m" & set "FF_Green=102m" set "FF_Yellow=103m" & set "FF_Blue=104m" & set "FF_Magenta=105m" set "FF_Cyan=106m" & set "FF_White=107m" :: DEMO echo. echo ONLY BACKGROUND COLORS %<%%BB_Red% RED %>% ^& %<%%BB_Green% GREEN %>% echo ONLY FOREGROUND COLORS %<%%FF_Magenta% MAGNETA %>% ^& %<%%F_Yellow% YELLOW %>% echo COMBINATION COLORS ^& STYLE %<%%FF_Black:m=;%%B_Green:m=;%%Bold%F:BLACK B:GREEN S:BOLD%>% Alternative to Manual write ALT 0-2-7 Code: for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do set "ESC=%%b"&goto:SetEsc :SetEsc set "<=%ESC%[" set ">=%ESC%[0m"
Found this years ago & it's been handy: Spoiler: colour.bat Code: @echo off cls echo [101;93m STYLES [0m echo ^<ESC^>[0m [0mReset[0m echo ^<ESC^>[1m [1mBold[0m echo ^<ESC^>[4m [4mUnderline[0m echo ^<ESC^>[7m [7mInverse[0m echo. echo [101;93m NORMAL FOREGROUND COLORS [0m echo ^<ESC^>[30m [30mBlack[0m (black) echo ^<ESC^>[31m [31mRed[0m echo ^<ESC^>[32m [32mGreen[0m echo ^<ESC^>[33m [33mYellow[0m echo ^<ESC^>[34m [34mBlue[0m echo ^<ESC^>[35m [35mMagenta[0m echo ^<ESC^>[36m [36mCyan[0m echo ^<ESC^>[37m [37mWhite[0m echo. echo [101;93m NORMAL BACKGROUND COLORS [0m echo ^<ESC^>[40m [40mBlack[0m echo ^<ESC^>[41m [41mRed[0m echo ^<ESC^>[42m [42mGreen[0m echo ^<ESC^>[43m [43mYellow[0m echo ^<ESC^>[44m [44mBlue[0m echo ^<ESC^>[45m [45mMagenta[0m echo ^<ESC^>[46m [46mCyan[0m echo ^<ESC^>[47m [47mWhite[0m (white) echo. echo [101;93m STRONG FOREGROUND COLORS [0m echo ^<ESC^>[90m [90mWhite[0m echo ^<ESC^>[91m [91mRed[0m echo ^<ESC^>[92m [92mGreen[0m echo ^<ESC^>[93m [93mYellow[0m echo ^<ESC^>[94m [94mBlue[0m echo ^<ESC^>[95m [95mMagenta[0m echo ^<ESC^>[96m [96mCyan[0m echo ^<ESC^>[97m [97mWhite[0m echo. echo [101;93m STRONG BACKGROUND COLORS [0m echo ^<ESC^>[100m [100mBlack[0m echo ^<ESC^>[101m [101mRed[0m echo ^<ESC^>[102m [102mGreen[0m echo ^<ESC^>[103m [103mYellow[0m echo ^<ESC^>[104m [104mBlue[0m echo ^<ESC^>[105m [105mMagenta[0m echo ^<ESC^>[106m [106mCyan[0m echo ^<ESC^>[107m [107mWhite[0m echo. echo [101;93m COMBINATIONS [0m echo ^<ESC^>[31m [31mred foreground color[0m echo ^<ESC^>[7m [7minverse foreground ^<-^> background[0m echo ^<ESC^>[7;31m [7;31minverse red foreground color[0m echo ^<ESC^>[7m and nested ^<ESC^>[31m [7mbefore [31mnested[0m echo ^<ESC^>[31m and nested ^<ESC^>[7m [31mbefore [7mnested[0m pause
On build 10586 and higher, KVA uses ANSI colors https://gist.github.com/mlocati/fdabcaeb8071d5c75a2d51712db24011 and on the other builds, it uses batch script based this solution https://stackoverflow.com/a/10407642 (it's used instead of other shortcodes because of compatibility with non-English characters).
It is based on script you mention above, A user friendly version Like the saying, work smart, not hard. Code: echo %<% %Color% something to color %>%
Colorful enough for ya? Code: ::# lean xp+ color macros by AveYo: %<%:af " hello "%>>% & %<%:cf " w\"or\"ld "%>% for single \ / " use .%|%\ .%|%/ \"%|%\" for /f "delims=:" %%s in ('echo;prompt $h$s$h:^|cmd /d') do set "|=%%s"&set ">>=\..\c nul&set /p s=%%s%%s%%s%%s%%s%%s%%s<nul&popd" set "<=pushd "%appdata%"&2>nul findstr /c:\ /a" &set ">=%>>%&echo;" &set "|=%|:~0,1%" &set /p s=\<nul>"%appdata%\c" And it works all the way to XP! that's dinosaur level, not ansi colors that microsoft took forever to add [edit] replace back public with appdata to fix xp - thanks Dark Monkey! %<%:af "hello"%>% where %<%: starts line, af is like the color command, then "text", immediately after %>% to end line or %>>% without CRLF so that you can chain multiple colors on the same line: %<%:af " hello "%>>% & %<%:f5 " MDL "%>>% & %<%:cf " forums "%>%
Definitely used it in XP. But since it's pretty much dead for many years, haven't bothered tested again after I have last adjusted the 2 lines snippet the issue is with %PUBLIC% variable - come to think about it it was not necessary to change from %APPDATA% damn, xp setup is so fast! and look at that taskbar! so much better than 11