0

So there is such things as the "colorecho" command but I want to set a command to a different colour such as task list your text the code below will colour that text aqua but i want to set a command to a different colour is there a way t do this?

@Echo Off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do     rem"') do (
  set "DEL=%%a"
)
call :colorEcho b "This is colored green with a black background!"
echo.
pause
exit
:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i

Tried "colortasklist"

@Echo Off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do     rem"') do (
  set "DEL=%%a"
)
call :colorEcho b "This is colored green with a black background!"
echo.
pause
exit
:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i
  • `colorEcho` is a subroutine, not a command. It doesn't colorize the `echo` command, it allows the user to display colors (there are better alternatives [here](https://stackoverflow.com/questions/4339649/how-to-have-multiple-colors-in-a-windows-batch-file) (although interestingly, this question isn't a duplicate of that one) if you're using Windows 10 or later). You can colorize the output of any command you'd like, but you'll have to use those techniques and some wrapper script to do it. – SomethingDark Feb 01 '23 at 11:31
  • As SomethingDark mentioned, you can use Terminal Escape sequences with Windows 10 or later. [Virtual Terminal Sequences](https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences). Set an escape character with `for /f %%e in ('echo prompt $E^|cmd') do set "\e=%%e"` then set the colors with something like `set "blueCol=%\e%[34m" & set "defaultCol=%\e%[97m"` then use those values like `echo %blueCol%This is blue. %defaultCol%This is back to the default.` – Qwerty Feb 01 '23 at 13:18

0 Answers0