[英]Is it possible to redirect the output of a batch file inside the script?
我想將批處理腳本的標准輸出設置為轉到文件。 如果可能的話,我想在腳本中執行此操作。
注:我不想這樣做: foo.bat > StdOut.txt
我想在腳本中做一些事情來將輸出重定向到文件
例如:
foo.bat
:: Redirect standard output to StdOut.txt
:: Insert batch code to do what I want here.
其中一種方法是: 使用call
命令在腳本中執行標簽。 編輯我意識到我發布的第一個版本似乎不能在cmd.exe提示符下工作(我使用的是TCC)。 以下似乎適用於兩個命令處理器:
@echo off
call :testitout > t.tmp
goto:eof
:testitout
echo Hi There
echo Goodbye
>是標准,所以你或多或少地堅持下去; 但是,您可以在批處理文件中移動它:
foo.bat:
@echo off
@echo Start File > StdOut.txt
@dir >> StdOut.txt
@echo End File >> StdOut.txt
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.