用法很简单: abc.cmd |发球out1.txt> out2.txt 或者,您可以使用Windows脚本宿主(WSH)编写自己的tee实施-无需下载任何exe文件! triggeradeadcat尝试这样做,但是该实现存在缺陷,因为它使用基于行的输入/输出而不是基于字符的输入/输出.如果该命令在同一行上具有交互式提示和响应,它将无法正常工作.下面是我在许多项目中使用过的便捷的JScript实现.我使用混合JScript/批处理技术,以便无需指定CSCRIPT即可直接调用该实用程序. @if(@X)==(@ Y)@end/*以JScript注释开头的无害混合行:: --- JScript注释中的Batch部分调用了内部JScript ----@回声关闭cscript//E:JScript//nologo%〜f0"%*退出/b----- JScript注释的结尾,普通JScript的开头------------------ */var fso = new ActiveXObject("Scripting.FileSystemObject");var mode = 2;如果(WScript.Arguments.Count()== 2){mode = 8;}var out = fso.OpenTextFile(WScript.Arguments(0),mode,true);var chr;while(!WScript.StdIn.AtEndOfStream){chr = WScript.StdIn.Read(1);WScript.StdOut.Write(chr);out.Write(chr);} 同样,用法很简单: abc.cmd |发球out1.txt> out2.txt Given a windows .cmd file abc.cmdabc.cmd > output.logThe above command line operation would save the output of the execution to output.log file.Are there options for running this command so as to create multiple copies of this log. That is, I want one copy created in one location, and another in a different location.Please do not ask my to run a copy command. I am looking for command line "options". 解决方案 Any Windows implementation of the unix tee command would work perfectly. There are free options out there. I like to use the GNU utilities for Windows, which includes tee.exe.Usage is simple:abc.cmd | tee out1.txt >out2.txtOr, you could write your own implementation of tee using Windows Scripting Host (WSH) - no exe to download! triggeradeadcat attempted to do so, but that implementation is flawed because it uses line based input/output instead of character based. It will not work well if the command has interactive prompts and responses on the same line.Below is a handy JScript implementation that I have used in many projects. I use hybrid JScript/batch techniques so that the utility can be called directly without having to specify CSCRIPT.@if (@X)==(@Y) @end /* Harmless hybrid line that begins a JScript comment::--- Batch section within JScript comment that calls the internal JScript ----@echo offcscript //E:JScript //nologo "%~f0" %*exit /b----- End of JScript comment, beginning of normal JScript ------------------*/var fso = new ActiveXObject("Scripting.FileSystemObject");var mode=2;if (WScript.Arguments.Count()==2) {mode=8;}var out = fso.OpenTextFile(WScript.Arguments(0),mode,true);var chr;while( !WScript.StdIn.AtEndOfStream ) { chr=WScript.StdIn.Read(1); WScript.StdOut.Write(chr); out.Write(chr);}Again, the usage is simple:abc.cmd | tee out1.txt >out2.txt 这篇关于Windows .cmd标准输出-多重重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-04 13:57