Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Windows VB Script properties for network conections

Posted on 2006-03-23
7
Medium Priority
?
322 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
0
Comment
Question by:rcabeca
7 Comments
 
LVL 8

Expert Comment

by:Leo Eikelman
ID: 16273535
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
0
 

Author Comment

by:rcabeca
ID: 16275042
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
0
 
LVL 8

Assisted Solution

by:Leo Eikelman
Leo Eikelman earned 100 total points
ID: 16275168
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

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:rcabeca
ID: 16275577
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
0
 
LVL 4

Assisted Solution

by:dasmcse
dasmcse earned 500 total points
ID: 16277095
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.
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 1400 total points
ID: 16279807
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
0
 

Author Comment

by:rcabeca
ID: 16280417
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
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

572 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