Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SUB CJtest
- DIM strCommand, WshShell, WshShellExec, strOutput
- Const WshFinished = 1
- Const WshFailed = 2
- strCommand = "ping.exe 127.0.0.1"
- Set WshShell = CreateObject("WScript.Shell")
- Set WshShellExec = WshShell.Exec(strCommand)
- On Error Resume Next
- Dim line, linecount
- WHILE WshShellExec.Status = 0
- line = vbNullString
- line = WshShellExec.StdOut.ReadLine()
- If line <> vbNullString Then
- strOutput = strOutput & line & vbCrLf
- linecount = linecount + 1
- End If
- WEND
- Select Case WshShellExec.Status
- Case WshFinished
- Do
- line = WshShellExec.StdOut.ReadLine()
- If line <> vbNullString Then
- strOutput = strOutput & line & vbCrLf
- linecount = linecount + 1
- End If
- Loop While Not WshShellExec.Stdout.atEndOfStream
- Case WshFailed
- strOutput = WshShellExec.StdErr.ReadAll
- End Select
- MsgBox strOutput
- MsgBox linecount
- END SUB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement