how to get local TCP/IP settings from Local Area Connections 
Author Message
 how to get local TCP/IP settings from Local Area Connections

Hi,

For me work I need to retrieve the TCP/IP settings (IP address, gateway,
DNS servers, Wins servers) from the local system.
Anyone an idea how to do it?
Thanks in advance,

Joanita.



Tue, 04 Jan 2005 13:19:11 GMT  
 how to get local TCP/IP settings from Local Area Connections
Hi Joanita,

Thank you for using Microsoft News Group.

If you are using Windows 2K,  you can query "Windows Management
Instrumentation"

Here is a sample.

Private Sub Command1_Click()

Set IPConfigSet =
GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
        ("SELECT IPAddress, DefaultIPGateway, DNSServerSearchOrder,
WINSPrimaryServer " & _
         "FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE")

If Err <> 0 Then
    MsgBox "Error: " & Err
End If

For Each ipconfig In IPConfigSet
    If Not IsNull(ipconfig.IPAddress) Then
        For i = LBound(ipconfig.IPAddress) To UBound(ipconfig.IPAddress)
            Debug.Print "IP Address: " & ipconfig.IPAddress(i)
        Next
    End If

    If Not IsNull(ipconfig.DefaultIPGateway) Then
        For i = LBound(ipconfig.DefaultIPGateway) To
UBound(ipconfig.DefaultIPGateway)
            Debug.Print "Default IP Gateway: " &
ipconfig.DefaultIPGateway(i)
        Next
    End If

    If Not IsNull(ipconfig.DNSServerSearchOrder) Then
        For i = LBound(ipconfig.DNSServerSearchOrder) To
UBound(ipconfig.DNSServerSearchOrder)
            Debug.Print "DNS Server: " & ipconfig.DNSServerSearchOrder(i)
        Next
    End If

    If Not IsNull(ipconfig.WINSPrimaryServer) Then
        Debug.Print "WINS Server: " & ipconfig.WINSPrimaryServer
    End If
Next

End Sub

For more information, please refer to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmis...
using_wmi.asp

--
Parker Zhang
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.



Fri, 07 Jan 2005 19:40:06 GMT  
 how to get local TCP/IP settings from Local Area Connections
Thanks a lot Parker,

I'll use it.

Regards,
Joanita

Quote:

> Hi Joanita,

> Thank you for using Microsoft News Group.

> If you are using Windows 2K,  you can query "Windows Management
> Instrumentation"

> Here is a sample.

> Private Sub Command1_Click()

> Set IPConfigSet =
> GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
>         ("SELECT IPAddress, DefaultIPGateway, DNSServerSearchOrder,
> WINSPrimaryServer " & _
>          "FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE")

> If Err <> 0 Then
>     MsgBox "Error: " & Err
> End If

> For Each ipconfig In IPConfigSet
>     If Not IsNull(ipconfig.IPAddress) Then
>         For i = LBound(ipconfig.IPAddress) To UBound(ipconfig.IPAddress)
>             Debug.Print "IP Address: " & ipconfig.IPAddress(i)
>         Next
>     End If

>     If Not IsNull(ipconfig.DefaultIPGateway) Then
>         For i = LBound(ipconfig.DefaultIPGateway) To
> UBound(ipconfig.DefaultIPGateway)
>             Debug.Print "Default IP Gateway: " &
> ipconfig.DefaultIPGateway(i)
>         Next
>     End If

>     If Not IsNull(ipconfig.DNSServerSearchOrder) Then
>         For i = LBound(ipconfig.DNSServerSearchOrder) To
> UBound(ipconfig.DNSServerSearchOrder)
>             Debug.Print "DNS Server: " & ipconfig.DNSServerSearchOrder(i)
>         Next
>     End If

>     If Not IsNull(ipconfig.WINSPrimaryServer) Then
>         Debug.Print "WINS Server: " & ipconfig.WINSPrimaryServer
>     End If
> Next

> End Sub

> For more information, please refer to
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmis...
> using_wmi.asp

> --
> Parker Zhang
> Microsoft Developer Support

> This posting is provided "AS IS" with no warranties, and confers no rights.



Wed, 12 Jan 2005 03:22:19 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. scanning a local tcp/ip enabled computer

2. help with setting up dial-up connection and internet tcp/ip settings through vbasic 4.0

3. help with setting up dial-up connection and internet tcp/ip settings through vbasic 4.0

4. help with setting up dial-up connection and internet tcp/ip settings through vbasic 4.0

5. VBScript to uncheck boxes in Properties of a Local Area Connection

6. Disable Local Area Connection

7. How to disable-Enable Local area Connection via script

8. Enable/Disable Local Area Connection

9. Monitoring Dialup Networking and Getting Local IP

10. Getting Local IP address running a VBS script locally

11. Getting Local IP Address of Machine

12. Getting IP Address of Local Machine

 

 
Powered by phpBB® Forum Software