我的VBScript没有显示我执行的任何命令的结果.我知道命令被执行但我想捕获结果.
我已经测试了很多方法,例如:
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
Run Code Online (Sandbox Code Playgroud)
但它不打印任何结果.如何捕捉StdOut和StdErr?
vbscript ×1