i working on project, , problem, when try motherboard serial number totally empty.
dim hwid string = string.empty dim mcl new managementclass("win32_processor") dim mobc managementobjectcollection = mcl.getinstances() each mob managementobject in mobc if hwid = "" hwid = mob.properties("processorid").value.tostring() exit end if next dim mboardstr string = nothing dim mbs managementobjectsearcher = new managementobjectsearcher("select * win32_baseboard") each mo managementobject in mbs.get mboardstr = mboardstr + mo("serialnumber").tostring next msgbox(mboardstr)
hwid - processorid okey, want motherboard serial too, because after put 1 string , post remote host.
why dont have "serialnumber"? thanks!
not data available on systems. in case, there might other data ahead of text looking prevents string being fetched. wmi pretty slow, can speed querying after (vs select *
).
some of things should disposed of release resources , should check of things make sure not null before using them:
dim mboardstr string = "" dim query string = "select serialnumber win32_baseboard" using mbs managementobjectsearcher = new managementobjectsearcher(query) each mo managementobject in mbs.get each pd propertydata in mo.properties ' should 1 if pd.name = "serialnumber" ' value object, test nothing if pd.value isnot nothing mboardstr = pd.value.tostring end if exit end if next next end using
you set breakpoint, , examine pd.value
see if there leading nuls or other unprintable control characters (quite common). after might "behind" them.
Comments
Post a Comment