We help IT Professionals succeed at work.

Windows VB Script properties for network conections

rcabeca
rcabeca asked
on
Medium Priority
352 Views
Last Modified: 2007-12-19
Howdy,
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?
Thansk
Robert
Comment
Watch Question

Leo EikelmanDirector, IT and Business Development

Commented:
Well you can try this article

http://www.ftponline.com/archives/premier/mgznarch/VBPJ/1999/09sep99/cb0999.pdf

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

See this article

http://www.sysinternals.com/Utilities/PsExec.html

Hope this helps a bit,

Leo

Author

Commented:
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?
rc
Leo EikelmanDirector, IT and Business Development
Commented:
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.

http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=30786&lngWId=1

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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.
Thansk!
Robert
Commented:
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 "
objWshShell.run (strCMD & "netstat.exe" & " > c:\textfile.txt")

'now just read the data in the file.
Commented:
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)

Do
   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

Commented:
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.
Regards,
Robert Cabeca
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.