How to echo with different colors in the Windows command line

前端 未结 23 1256
野性不改
野性不改 2020-11-22 08:55

I know that the color bf command sets the colors of the whole command line window but I wanted to to print one single line in a different color.

23条回答
  •  灰色年华
    2020-11-22 09:43

    for me i found some solutions: it is a working solution

         @echo off
        title a game for youtube 
    explorer "https://thepythoncoding.blogspot.com/2020/11/how-to-echo-with-different-colors-in.html"
        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"
        )
        echo say the name of the colors, don't read
        
        call :ColorText 0a "blue"
        call :ColorText 0C "green"
        call :ColorText 0b "red"
        echo(
        call :ColorText 19 "yellow" 
        call :ColorText 2F "black"
        call :ColorText 4e "white"
        
        goto :Beginoffile
        
        :ColorText
        echo off
         "%~2"
        findstr /v /a:%1 /R "^$" "%~2" nul
        del "%~2" > nul 2>&1
        goto :eof
        
        :Beginoffile
    

提交回复
热议问题