|
之前使用一直正常,今天打开忽然间不能用了,换电脑也不行,求助大神帮忙看看是哪里问题,感谢。
方法 Exec 作用于对象IWshShell3时失败
- Sub 宏1()
- Dim objWSShell, IP, strEcho
- Set objWSShell = CreateObject("Wscript.shell")
- Dim oExec As Object
- IP = "172.0.0.1"
- 'IP = "123.123.123.123"
- cmdping = "ping " & IP & " -n 1"
- Set oExec = objWSShell.Exec(cmdping)
- Do Until oExec.stdout.AtEndOfStream
- strEcho = strEcho & oExec.stdout.readline() & Chr(13)
- Loop
- Debug.Print strEcho
- If InStr(strEcho, "Lost = 0 (0% loss)") Or InStr(strEcho, "丢失 = 0 (0% 丢失)") Then
- MsgBox "通过"
-
- Else
- MsgBox "不通过"
- End If
-
- End Sub
复制代码
|
|