query excluding empty or null results (Full Version)

All Forums >> [Scripting Technologies] >> Windows Management Instrumentation



Message


scooper759 -> query excluding empty or null results (10/9/2008 4:23:47 PM)

This snippet is intended to create a collect of network adapters not microsoft and contain a macaddress yet, it seems to ignor the macaddress query parameter by listing adapters without macaddres values. Vartype shows the empty macaddress values as type1 (vbNull).  Anyone have an idea how to get a list of adapters only with macaddress values. I've tried other null and empty string options in the query, I'm going nuts. Thanks

Set oLocator = CreateObject("WbemScripting.SWbemLocator")
Set oService = oLocator.ConnectServer(sServer,sNameSpace,sUserName,sPassword)
set oInstances = oService.ExecQuery("SELECT * from Win32_NetworkAdapter where _
Manufacturer <> 'Microsoft' AND MACAddress <> " & vbNull & "")

wscript.Echo oInstances.Count
For each oAdapter in oInstances
wscript.Echo oAdapter.deviceid, oAdapter.Manufacturer, Vartype(oAdapter.MacAddress)
Next

Thanks




scooper759 -> RE: query excluding empty or null results (10/13/2008 5:26:36 PM)

Not a WMI issue but a scripting problem. There is a differance between vbNull and NULL so replacing vbNull with NULL resolves this.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.171875