WinPE
asked on
VBSCRIPT - Get IP address, how is it storing in the array. How to extract XXX.XXX.XXX.
Can someone explain this code to me a little better, I understand that it pulls from the network adapters class and grabs all not null ip addresses. I see then that it stores it in a ran, but not familiar enough with arrays, I dont understand how hes doing it.
Bottom line, I need to extract the first three octects of this data. The XXX.XXX.XXX, so that I can do a subnet compare afterwards. Unfortunatly I have failed, im guessing b/c I dont really understand how its storing it in the first place.
I have to use this IP schema code. Thanks in advance.
Bottom line, I need to extract the first three octects of this data. The XXX.XXX.XXX, so that I can do a subnet compare afterwards. Unfortunatly I have failed, im guessing b/c I dont really understand how its storing it in the first place.
I have to use this IP schema code. Thanks in advance.
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True",,48)
i = -1
For Each objItem in colItems
i = i + 1
ReDim Preserve arrNetadapter_Description(i), arrNetadapter_MACAddress(i)
ReDim Preserve arrNetadapter_DNSHostName(i)
ReDim Preserve arrNetadapter_DHCPEnabled(i)
ReDim Preserve arrNetadapter_DHCPServer(i)
ReDim Preserve arrNetadapter_DNS(i)
ReDim Preserve arrNetadapter_WINSPrimaryServer(i)
ReDim Preserve arrNetadapter_WINSSecondaryServer(i)
arrNetadapter_Description(i) = objItem.Description
arrNetadapter_MACAddress(i) = objItem.MACAddress
arrNetadapter_DNSHostName(i) = objItem.DNSHostName
arrNetadapter_DHCPEnabled(i) = objItem.DHCPEnabled
arrNetadapter_DHCPServer(i) = objItem.DHCPServer
arrNetadapter_DNS(i) = objItem.DNSDomain
arrNetadapter_WINSPrimaryServer(i) = objItem.WINSPrimaryServer
arrNetadapter_WINSSecondaryServer(i) = objItem.WINSSecondaryServer
If Not IsNull(objItem.IPAddress) Then
For j = 0 To UBound(objItem.IPAddress)
If (j > UBound(arrNetadapter_IPAddress,2)) Then
ReDim Preserve arrNetadapter_IPAddress(nMaxNetworkAdapters,j)
End If
arrNetadapter_IPAddress(i,j) = objItem.IPAddress(j)
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No worries - glad to help.
ASKER