Sorry to revisit this topic again but now I would like to eliminate the displayed IP address 0.0.0.0 where a station has tow network cards and one is disconnected or where a laptop has not yet been logged on by a member of staff. I have tried a logon script:
[and a companion setting in BGINFO.BGI to get the contents of ip.txt]
for /f "delims=: tokens=1-2" %%c in ('ipconfig /all ^| find "Ip-address"') do set GetIP=%%d
endlocal & set GetIP=%GetIP:~1%
echo %GetIP% > "%TEMP%\ip.txt"
however the script does not work. It just echoes '~1' to ip.txt.
I have also tried:
That gives an error part way through the file [line 24 I think]
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True",,48)
strIPAddresses = ""
For Each objItem In colItems
For Each address In objItem.IPAddress
blnValidIP = (InStr (address, ".") > 0) _
And (InStr (objItem.Caption, "VMware Virtual") = 0) _
And address <> "0.0.0.0"
If blnValidIP Then
strIPAddresses = strIPAddresses & address & "|"
If Len (strIPAddresses) > 0 Then
strIPAddresses = Left (strIPAddresses,Len(strIPAddresses)-1)
strIPAddresses = Replace (strIPAddresses, "|", ", ")
strIPAddresses = "(disconnected)"
I have also tried telling BGINFO only to display IPs from network cards if they are enabled [connected to a network] I can't remember what I put in for that but it was something like:
but BGINFO displays an error like this:
SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True
Does anyone know how I can get rid of these 'dead' IPs from my desktops?
Query not in from 'SELECT xxx FROM...'