這不是一個很好的答案,但是如果您知道目標工作站有Powershell,您可以這樣做(假設BAT/CMD腳本):
CALL:ECHORED "Print me in red!"
:ECHORED
%Windir%\System32\WindowsPowerShell\v1.0\Powershell.exe write-host -foregroundcolor Red %1
goto:eof
編輯:(現(xiàn)在更簡單了!)
這是個老掉牙的答案,但我想我應該澄清一下,簡化一點
Powershell現(xiàn)在包括在內(nèi)所有版本因此,這個答案的語法可以縮短為一個更簡單的形式:
- 這個
路徑
不需要指定,因為它應該已經(jīng)在環(huán)境變量中了。 毫不含糊
命令可以是縮略
..例如,您可以:- 使用
-fore
而不是-foregroundcolor
- 使用
-back
而不是-backgroundcolor
- 這個命令基本上也可以用來‘
內(nèi)聯(lián)
代替echo
(而不是像上面那樣創(chuàng)建單獨的批處理文件)。
例子:
powershell write-host -fore Cyan This is Cyan text
powershell write-host -back Red This is Red background
更多資料:
顏色和更多信息的完整列表可在
- Powershell文件Write-Host