:colored_echo [Текст] [Цвет текста] [Цвет фона] [Новая строка (0/1)] if not defined e ( pushd "%temp%" if not exist e.txt ( ::Скрипт на VBS, который записывает в e.txt символ Escape (27) ::Сам e.txt не удаляется, чтобы лишний раз не запускать скрипт (не думаю, что юзер пострадает от файла размером в 1 байт) echo Set f = CreateObject^("Scripting.FileSystemObject"^).CreateTextFile^("e.txt",True^)> we.vbs echo f.Write Chr^(27^)>> we.vbs echo f.Close>> we.vbs cscript //nologo we.vbs del we.vbs ) ::Запись символа Escape в переменную for /f %%i in (e.txt) do set "e=%%i" popd ) ::Значения по умолчанию для цветов set fgc=0 set bgc=40 ::Цвет текста if "%~2"=="default" goto select_bgc if "%~2"=="black" set fgc=30& goto select_bgc if "%~2"=="red" set fgc=31& goto select_bgc if "%~2"=="green" set fgc=32& goto select_bgc if "%~2"=="yellow" set fgc=33& goto select_bgc if "%~2"=="blue" set fgc=34& goto select_bgc if "%~2"=="magenta" set fgc=35& goto select_bgc if "%~2"=="cyan" set fgc=36& goto select_bgc if "%~2"=="lgray" set fgc=37& goto select_bgc if "%~2"=="dgray" set fgc=90& goto select_bgc if "%~2"=="lred" set fgc=91& goto select_bgc if "%~2"=="lgreen" set fgc=92& goto select_bgc if "%~2"=="lyellow" set fgc=93& goto select_bgc if "%~2"=="lblue" set fgc=94& goto select_bgc if "%~2"=="lmagenta" set fgc=95& goto select_bgc if "%~2"=="lcyan" set fgc=96& goto select_bgc if "%~2"=="white" set fgc=97& goto select_bgc ::Цвет фона :select_bgc if "%~3"=="default" goto write_text if "%~3"=="black" set bgc=40& goto write_text if "%~3"=="red" set bgc=41& goto write_text if "%~3"=="green" set bgc=42& goto write_text if "%~3"=="yellow" set bgc=43& goto write_text if "%~3"=="blue" set bgc=44& goto write_text if "%~3"=="magenta" set bgc=45& goto write_text if "%~3"=="cyan" set bgc=46& goto write_text if "%~3"=="lgray" set bgc=47& goto write_text if "%~3"=="dgray" set bgc=100& goto write_text if "%~3"=="lred" set bgc=101& goto write_text if "%~3"=="lgreen" set bgc=102& goto write_text if "%~3"=="lyellow" set bgc=103& goto write_text if "%~3"=="lblue" set bgc=104& goto write_text if "%~3"=="lmagenta" set bgc=105& goto write_text if "%~3"=="lcyan" set bgc=106& goto write_text if "%~3"=="white" set bgc=107& goto write_text ::Вывод текста :write_text if "%~4"=="1" ( ::Обычный echo (с переходом на новую строку) echo %e%[%fgc%m%e%[%bgc%m%~1%e%[0m ) else ( ::Вариант без перехода на новую строку set /p "_=%e%[%fgc%m%e%[%bgc%m%~1%e%[0m" < nul ) goto :eof