How to echo with different colors in the Windows command line

前端 未结 23 1674
野性不改
野性不改 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:49

    I looked at this because I wanted to introduce some simple text colors to a Win7 Batch file. This is what I came up with. Thanks for your help.

    @echo off
    cls && color 08
    
    rem .... the following line creates a [DEL] [ASCII 8] [Backspace] character to use later
    rem .... All this to remove [:]
    for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (set "DEL=%%a")
    
    echo.
    
     "%~2"
    findstr /v /a:%1 /R "+" "%~2" nul
    del "%~2" > nul
    goto :eof
    
    :end
    echo.
    pause
    

提交回复
热议问题