"Monitor" <nospam@xxxxxx> wrote in message
news:uQi07XQuIHA.1220@xxxxxx

>
> Nice solution! Two questions:
> - I copied your code verbatim to a .vbs file, without making any
> changes, then ran it on two machines. On one it ran flawlessly,
> on the other it generated an error message for this line of code:
>
> For Each strIPAddr In objNICConfig.IPAddress
>
> nic.vbs(19, 4) Microsoft VBScript runtime error: Object not a collection
Are all of your computers on a single subnet? If so, you can search for
the adapter within your subnet. See code below. If they are not, but are
contained within a single network, the code could be modified to set a
larger subnet mask outside of the loop.

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sNetwork = "10.0.0.0"



strComputer = "."
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = ObjWMI.ExecQuery("Select * from " _
& "Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")

For Each objItem in colItems
aIP = Split(objItem.IPAddress(0), ".")
aSM = Split(objItem.IPSubnet(0), ".")
sSubnet = Empty
For i = 0 to 3
sSubnet = sSubnet & (aIP(i) And aSM(i))
If i < 3 Then sSubnet = sSubnet & "."
Next
If sSubnet = sNetwork Then Exit For Else aIP = Null
Next

Select Case IsNull(aIP)
Case False MsgBox Join(aIP, ".")
Case True MsgBox "No Match NIC Found!", vbCritical
End Select
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~