是否可以在脚本中重定向批处理文件的输出?

SwD*_*n81 8 windows scripting batch-file

我想将批处理脚本的标准输出设置为转到文件.如果可能的话,我想在脚本中执行此操作.

注:希望这样做:foo.bat > StdOut.txt

我想在脚本中做一些事情来将输出重定向到文件
例如:

foo.bat

:: Redirect standard output to StdOut.txt
:: Insert batch code to do what I want here.
Run Code Online (Sandbox Code Playgroud)

Mar*_*ins 14

其中一种方法是:使用该call命令在脚本中执行标签. 编辑我意识到我发布的第一个版本似乎不能在cmd.exe提示符下工作(我使用的是TCC).以下似乎适用于两个命令处理器:

@echo off
call :testitout > t.tmp
goto:eof

:testitout
echo Hi There
echo Goodbye
Run Code Online (Sandbox Code Playgroud)