Windows VB Script properties for network conections

Posted on 2006-03-23
Last Modified: 2007-12-19
I have a script that will run on 900+ servers and i am looking for a method/property whre i can determine if specific network connections are established for a new application we deployed. I have tried to use teh Win32_performattedData_TCPIP_TCP, Win32_Networkconnections, Win32_perfrawdata_TCPIP_TCP and Win32_Process to try and see if there were any properties that would give me this info, but it does not.

Does anyone know how i can pull in the port connection states into a script?
Question by:rcabeca
    LVL 8

    Expert Comment

    by:Leo Eikelman
    Well you can try this article

    You can also use netstat to see what connections are established.

    See this article

    Hope this helps a bit,


    Author Comment

    Thanks for the links, but i don't think i want to use a .dll if i can avoid it. Is there a way to enumerate the network connections by using "netstat" in a script and extracting the info from it?
    LVL 8

    Assisted Solution

    by:Leo Eikelman
    Check this out.  I didn't have time to check if this use the DLL or not, but if it doesn't then it can be a big help.


    Author Comment

    Thanks but this is a stand alone application that gives everything about all network resources. I tried to extract from it what i needed, but it does not gel with the vbs script that i am creating. My script is already 300 lines. I just need to know What object/property/method/class and it is driving me crazy trying to find it.
    LVL 4

    Assisted Solution

    How about executing netstat within your script and redirect the output to a text file. Your script could then parse the text file for the info.
    Set objWshShell = WScript.CreateObject("WScript.Shell")
    strCMD =  objWSHShell.ExpandEnvironmentStrings("%COMSPEC%") & " /C " (strCMD & "netstat.exe" & " > c:\textfile.txt")

    'now just read the data in the file.
    LVL 28

    Accepted Solution

    You could also use netstat without the need to redirect to a text file.
    Dim oShell,oExec,sCmd,sRetVal

    sCmd = "netstat"

    Set oShell = CreateObject("WScript.Shell")
    Set oExec = oShell.Exec(sCmd)

       sRetVal = oExec.StdOut.ReadLine()       
       if Instr(sRetVal,"ESTABLISHED") > 0 then
             MsgBox sRetVal
       end if
    Loop While Not oExec.StdOut.AtEndOfStream

    Set oExec = Nothing
    Set oShell = Nothing

    Author Comment

    Thanks Vinnyd79! You gave me just what i was looking for. Dasmcse, i would have used yours, but using the text file method and parsing was a bit more involved.
    Thanks again all of you for providing your expertice.
    Robert Cabeca

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now