Login | |
|
 |
RE: Need help on redirecting output and search results ... - 12/14/2007 6:30:50 AM
|
|
 |
|
| |
trsix
Posts: 21
Score: 0
Joined: 12/6/2006
From: Vancouver BC
Status: offline
|
This might be what you are looking for... or atleast point you in the right direction This runs on the local system and displays each state in its own msgbox Dim strTimeWait, strEstablished, strListening, strCloseWait, strOther Dim objShell, objWshScriptExec, arrQueryOutput Set objShell = CreateObject("WScript.Shell") 'netstat actually provides the full information regarding the systems ports Set objWshScriptExec = objShell.exec ("netstat -a ") 'put the entire output of netstat -a into an object SET objOutput = objWshScriptExec.Stdout 'here you can choose what ever you want, i went with if/then's but you could use case While not objOutput.AtEndOfStream strLine = objOutput.ReadLine If Instr(strLine, "TIME_WAIT") <> 0 Then strTimeWait = strTimeWait & strLine & vbCrLf ElseIf Instr(strLine, "ESTABLISHED") <> 0 Then strEstablished = strEstablished & strLine & vbCrLf ElseIF Instr(strLine, "LISTENING") <> 0 Then strListening = strListening & strLine & vbCrLf ElseIF Instr(strLine, "CLOSE_WAIT") <> 0 Then strCloseWait = strCloseWait & strLine & vbCrLf Else strOther = strOther & strLine & vbCrLf End If WEnd 'output the final to msgboxes MsgBox("Time_Wait Connections" & vbCrLf & strTimeWait) MsgBox("Established Connections" & vbCrLf & strEstablished) MsgBox("Listening Connections" & vbCrLf & strListening) MsgBox("Close_Wait Connections" & vbCrLf & strCloseWait) MsgBox("Other Connections" & vbCrLf & strOther)
|
|
| |
|
|
|
|
|