Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Default Gateway IP address

Status
Not open for further replies.

smithy1981

IS-IT--Management
Sep 16, 2005
12
GB
Hi, I am trying to use vbscript to get the first two octets of the default gateway on a machine.

I can get the machines IP address, but not the Default Gateway IP.

Any suggestions?

Thanks
 
Something like this ?
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem In colItems
strIPAddress = Join(objItem.IPAddress, ",")
strDefaultIPGateway = Join(objItem.DefaultIPGateway, ",")
MsgBox "IP=" & strIPAddress & vbCrLf & "GW=" & strDefaultIPGateway
Next

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top