How to display IP using vbscript file?

Asked By 20 points N/A Posted on -
qa-featured

Hello TechyV users,
At first I want to let you know that I am a part time programmer by hobby. I make some small programs to make fun. Could you please give me a code that will display IP using vbscript file

SHARE
Answered By 25 points N/A #174806

How to display IP using vbscript file?

qa-featured

 

Hello Robert P Nunez,

Thanks for asking question in techyv. You are searching vbscript code for display IP address. To be honest I don’t have vast knowledge in VBScript. But I am searching in google for that. And at last find it. It works for me fine. Lets try yourself.

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

Thanking you again and stay with techyv for any query.

Related Questions