How to have multiple colors in a Windows batch file?

前端 未结 12 1476
我寻月下人不归
我寻月下人不归 2020-11-22 01:05

I was wondering if its possible to have different colored text on the same line in a Windows batch file, for example if it says

echo hi world
12条回答
  •  逝去的感伤
    2020-11-22 01:26

    If you have a modern Windows (that has powershell installed), the following may work fine as well

    call :PrintBright Something Something
    
      (do actual batch stuff here)
    
    call :PrintBright Done!
    goto :eof
    
    
    :PrintBright
    powershell -Command Write-Host "%*" -foreground "White"
    

    Adjust the color as you see fit.

提交回复
热议问题