是否有可能重定向脚本中的批处理文件的输出? [英] Is it possible to redirect the output of a batch file inside the script?
问题描述
我想建立一个批处理脚本的标准输出去到一个文件中。我想如果可能的话要做到这一点的脚本中。
注意:我的不的要做到这一点: foo.bat> StdOut.txt
我愿做脚本里面的东西输出重定向到一个文件结果
例如:
foo.bat
::标准输出重定向到StdOut.txt
::插入批次code做什么,我想在这里。
一做就是下面的方法。使用呼叫
命令的脚本来执行的标签。 修改我认识的第一个版本我张贴似乎并不在CMD.EXE提示工作(我是用TCC)。下面,似乎在这两个指令的处理器工作:
关闭@echo
致电:testitout> t.tmp
GOTO:EOF:testitout
回声您好
回声再见
I would like to set the standard output of a batch script to go to a file. I would like to do this inside the script if possible.
Note: I do not want to do this: foo.bat > StdOut.txt
I would like to do something inside the script to redirect the output to a file
For example:
foo.bat
:: Redirect standard output to StdOut.txt
:: Insert batch code to do what I want here.
One way of doing it is the following. Use the call
command to execute a label in the script. Edit I realized the first version I posted does not seem to work in a cmd.exe prompt (I was using TCC). The following seems to work in both command processors:
@echo off
call :testitout > t.tmp
goto:eof
:testitout
echo Hi There
echo Goodbye
这篇关于是否有可能重定向脚本中的批处理文件的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!