Rob van der Woude's Scripting Pages

VBScript Scripting Techniques > Network > IP Address(es)

Retrieve Your Computer's IP Address(es)

 

Win32_NetworkAdapterConfiguration
VBScript Code:
strQuery = "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE MACAddress > ''"

Set objWMIService = GetObject( "winmgmts://./root/CIMV2" )
Set colItems      = objWMIService.ExecQuery( strQuery, "WQL", 48 )

For Each objItem In colItems
    If IsArray( objItem.IPAddress ) Then
        If UBound( objItem.IPAddress ) = 0 Then
            strIP = "IP Address: " & objItem.IPAddress(0)
        Else
            strIP = "IP Addresses: " & Join( objItem.IPAddress, "," )
        End If
    End If
Next

WScript.Echo strIP
Requirements:
Windows version: Windows 2000, XP, Server 2003, or Vista
Network: TCP/IP
Client software: N/A
Script Engine: any
Summarized: Works in Windows 2000, XP, Server 2003 and Vista.
Doesn't work in Windows 95, 98, ME or NT 4.
 
[Back to the top of this page]

page last uploaded: 2016-09-19, 14:58