Announcement

Collapse
No announcement yet.

Open system ports

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Open system ports

    I need to add open & listening ports to a script for writing out a system's configuration but since there are not a lot of options to get this I thought I could catpure the output from netstat -ao |find /i "listening".

    Set oWSHobj = CreateObject("WScript.shell")
    Set oExec = oWSHobj.exec("netstat -ano |find /i ""LISTENING""")
    strPortResults = oExec.StdOut.ReadAll

    Do until oExec.StdOut.AtEndOfStream
    strPortResults = oExec.StdOut.ReadAll
    Loop
    WScript.Echo strPortResults

    The redirect to find keeps the output from the StdOut.ReadAll capture, without the find it captures. I'd rather not write a regex if possible. Is there another untility I can use to capture the open and listing ports?

  • #2
    Re: Open system ports

    Does this help?
    Code:
    Set oWSHobj = CreateObject("WScript.shell")
    
    Set oExec = oWSHobj.exec("cmd.exe /c netstat -ano |find /i ""LISTENING""")
    
    strPortResults = oExec.StdOut.ReadAll
    
    WScript.Echo strPortResults
    \Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment

    Working...
    X