Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SUB CJtest
  2.  
  3. DIM strCommand, WshShell, WshShellExec, strOutput
  4.  
  5. Const WshFinished = 1
  6. Const WshFailed = 2
  7. strCommand = "ping.exe 127.0.0.1"
  8.  
  9. Set WshShell = CreateObject("WScript.Shell")
  10. Set WshShellExec = WshShell.Exec(strCommand)
  11.  
  12. On Error Resume Next
  13. Dim line, linecount
  14. WHILE WshShellExec.Status = 0
  15.     line = vbNullString
  16.     line = WshShellExec.StdOut.ReadLine()
  17.     If line <> vbNullString Then
  18.         strOutput = strOutput & line & vbCrLf
  19.         linecount = linecount + 1
  20.     End If
  21. WEND
  22.  
  23. Select Case WshShellExec.Status
  24.     Case WshFinished
  25.         Do
  26.             line = WshShellExec.StdOut.ReadLine()
  27.             If line <> vbNullString Then
  28.                 strOutput = strOutput & line & vbCrLf
  29.                 linecount = linecount + 1
  30.             End If
  31.         Loop While Not WshShellExec.Stdout.atEndOfStream
  32.     Case WshFailed
  33.         strOutput = WshShellExec.StdErr.ReadAll
  34. End Select
  35.  
  36. MsgBox strOutput
  37.  
  38. MsgBox linecount
  39.  
  40. END SUB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement