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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtain Default Gateway From Remote System? 1

Status
Not open for further replies.

Armstrong

IS-IT--Management
May 15, 2001
34
0
0
US

SUBJECT: Obtain Default Gateway From Remote System?

All,

I know you can do this via IPConfig |find "Default Gateway" via RCMD, but this is not sufficient. I also know that there is a SetGateways Method of the Win32_NetworkAdapterConfiguration Class, but there is no 'Get', 'List' or 'Show' equivalent method. This value is also stored in the Hive: HKEY_LOCAL_MACHINE
Key: System\ControlSet001\Services\<adapter name>\ Parameters\Tcpip. This is only good if you actually know the adapter ID on all of the 'Remote Systems' that you want to query.


Does anyone know of a method that you can at least steer me towards or perhaps someone has already tackled/solved this one.

TIA,

Greg

Greg Armstrong
A+ MCSE+I :)
 
Armstrong, maybe this will give you a start. Replace strComputer with remote PC name AND assumes you have appropriate rights to this box.Lifted and slightly modified from Microsoft at (IMHO a very good place to get ideas, etc. - not as good as tek-tips but good none the less)

Sub GetAllIPInfo

Set objWMIService = GetObject("winmgmts:\\"& strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

For Each objAdapter in colAdapters
strServerFile.Writeline vbCrlf & "Network Adapter Settings"
strServerFile.Writeline "========================"
strServerFile.Writeline "Description: " & objAdapter.Description
strServerFile.Writeline "MAC address: " & objAdapter.MACAddress
strServerFile.Writeline " Host name: " & objAdapter.DNSHostName
If Not IsNull(objAdapter.IPAddress) Then
For i = 0 To UBound(objAdapter.IPAddress)
strServerFile.Writeline " IP address: " & objAdapter.IPAddress(i)
Next
End If
If Not IsNull(objAdapter.IPSubnet) Then
For i = 0 To UBound(objAdapter.IPSubnet)
strServerFile.Writeline " Subnet: " & objAdapter.IPSubnet(i)
Next
End If
If Not IsNull(objAdapter.DefaultIPGateway) Then
For i = 0 To UBound(objAdapter.DefaultIPGateway)
strServerFile.Writeline "Default gateway: " & objAdapter.DefaultIPGateway(i)
Next
End If
strServerFile.Writeline vbCrlf & " DNS Settings"
strServerFile.Writeline "================"
strServerFile.Writeline "DNS servers in search order:"
If Not IsNull(objAdapter.DNSServerSearchOrder) Then
For i = 0 To UBound(objAdapter.DNSServerSearchOrder)
strServerFile.Writeline objAdapter.DNSServerSearchOrder(i)
Next
End If
strServerFile.Writeline "DNS domain: " & objAdapter.DNSDomain
If Not IsNull(objAdapter.DNSDomainSuffixSearchOrder) Then
For i = 0 To UBound(objAdapter.DNSDomainSuffixSearchOrder)
strServerFile.Writeline "DNS suffix search list: " & objAdapter.DNSDomainSuffixSearchOrder(i)
Next
End If

strServerFile.Writeline

Next

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top