【发布时间】:2018-07-31 17:20:01
【问题描述】:
我正在运行一个批处理文件,其中 std 输出被重定向到一个文件,我想在控制台上显示的输出中获取彩色文本。我找到了一些可以提供彩色文本的东西,但我不知道如何将它发送到控制台。这有效,但在重定向标准输出时无效: How to have multiple colors in a Windows batch file?
我这样调用批处理文件:
我的批处理 >myoutput.txt
我的批处理文件如下所示:
:: Sample Batch file
@echo off
@echo this goes to the text file when std output is redirected
@echo this goes to the console >CON
call :ColorText 19 "This uses the above referenced method to print in blue, but doesn't go to the console" & echo(
.
.
.
:ColorText
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
goto :eof
如何让该文本进入控制台?
【问题讨论】:
-
nul本身是什么意思? -
你需要把
goto :EOF放在:ColorText之前!变量DEL设置为什么? -
不确定 nul 是什么意思,只是从引用的链接复制/粘贴。
-
理解 goto :EOF...这只是示例代码
-
您似乎选择在 Jeb 的回答中仅使用部分所需代码。
标签: windows batch-file colors stdout