如何在Windows批處理文件中有多種顏色?我想知道是否有可能在Windows批處理文件中的同一行中有不同顏色的文本,例如,如果它說echo hi world我希望“嗨”是一種顏色,“世界”是另一種顏色。也許我可以將color命令設置為變量:set color1= color 2
set color9= color A然后將它們部署在同一條線上,同時echo hi world但我不知道我該怎么做。
3 回答

LEATH
TA貢獻1936條經驗 獲得超7個贊
@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" ) 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 :eof :ColorText echo off <nul set /p ".=%DEL%" > "%~2" findstr /v /a:%1 /R "^$" "%~2" nul del "%~2" > nul 2>&1 goto :eof
<backspace>
<backspace>
.
所有字符都是有效的。
@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" ) rem Prepare a file "X" with only one dot <nul > X set /p ".=." call :color 1a "a" call :color 1b "b" call :color 1c "^!<>&| %%%%"*?" exit /b :color set "param=^%~2" ! set "param=!param:"=\"!" findstr /p /A:%1 "." "!param!\..\X" nul <nul set /p ".=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%" exit /b
\..\

收到一只叮咚
TA貢獻1821條經驗 獲得超5個贊
call :PrintBright Something Something (do actual batch stuff here) call :PrintBright Done! goto :eof :PrintBright powershell -Command Write-Host "%*" -foreground "White"
- 3 回答
- 0 關注
- 1953 瀏覽
添加回答
舉報
0/150
提交
取消