@echo off
ping www.google.com > pinglog.txt
pause
我有这个命令,但我的问题是当你添加“>”或“>>”命令提示符不会显示后台发生的情况。有没有办法在执行ping后复制所有内容?
我也知道这段代码:
@echo off
ping www.google.com > pinglog.txt
type pinglog.txt
pause
但是,屏幕保持空白,好像什么都没发生一样。我希望有人可以提供帮助
答案 0 :(得分:0)
管道到Tee命令。
ping www.google.com | cscript //nologo tee.vbs - t pinglog.txt
这是来自filter.bat / vbs。
Set Arg = WScript.Arguments
set WshShell = createObject("Wscript.Shell")
Set Inp = WScript.Stdin
Set Outp = Wscript.Stdout
If LCase(Arg(0)) = "tee" or LCase(Arg(0)) = "t" then Tee
Sub Tee
On Error Resume Next
Set Fso = CreateObject("Scripting.FileSystemObject")
Set File = Fso.CreateTextFile(Arg(1), True)
If err.number <> 0 then
Outp.WriteLine "Error: " & err.number & " " & err.description & " from " & err.source
err.clear
wscript.exit
End If
Do Until Inp.AtEndOfStream
Line=Inp.readline
outp.writeline Line
File.WriteLine Line
Loop
End Sub
<强>三通强>
filter tee <Filename>
filter t <Filename>
将Stdin写入文件和StdOut
示例强>
filter tee "%userprofile%\Desktop\winini.txt" < "%windir%\win.ini"