我创建了一个VBScript,并且不知道为什么它不会回显结果。我知道cmd命令可以独立工作,如果我在那里结束脚本,因为我将参数设置为1并看到输出。
我也尝试将其存储为strObjPing
但不起作用
'' Sets up shell ''
Set objShell = CreateObject("Wscript.Shell")
'' Gets hostname ''
Dim strComputerName
strComputerName = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
'' Runs ping in cmd. Stores output. ''
Dim ObjPing
ObjPing = objShell.Run "ping " & strComputerName, 1, True
'' Execute program and read the output into a variable line by line ''
Dim strFromProc
Do
strFromProc = ObjPing.StdOut.ReadLine()
WScript.Echo "Output is: " & strFromProc
Loop While Not ObjPing.Stdout.atEndOfStream
objShell.Quit