我的VBScript不顯示任何我執行的命令的結果。我知道命令被執行,但我想捕獲結果。WScript.Shell.Exec - 從標準輸出讀取
我已經測試過這樣做,例如下面的方法很多:
Const WshFinished = 1
Const WshFailed = 2
strCommand = "ping.exe 127.0.0.1"
Set WshShell = CreateObject("WScript.Shell")
Set WshShellExec = WshShell.Exec(strCommand)
Select Case WshShellExec.Status
Case WshFinished
strOutput = WshShellExec.StdOut.ReadAll
Case WshFailed
strOutput = WshShellExec.StdErr.ReadAll
End Select
WScript.StdOut.Write strOutput 'write results to the command line
WScript.Echo strOutput 'write results to default output
但DOS不打印任何結果。我如何捕獲StdOut
和StdErr
?