Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WMI Win98

Status
Not open for further replies.

knela

Programmer
Jan 26, 2007
13
BR
Hello! I'm from Brazil so, forgive my english. I have a problem: I installed WMI in Windows 98 to get some informations, and one of this is the name of workgroup. I get the computer name, but when my function (thanks mgagnon!!!) trys to get the workgroup name I get this error message: "OLE error code 0x080020006: Unknown name". My function returns it correctly in Win XP.

objWMISvc = GETOBJECT("winmgmts:\\.\root\cimv2")
colItems = objWMISvc.ExecQuery("Select * from Win32_ComputerSystem", , 48)
FOR EACH objItem IN colItems
strComputerName = objItem.Name
strComputerDomain = objItem.WorkGroup
IF objItem.PartOfDomain
? "Computer Domain: " + strComputerDomain
ELSE
? "Workgroup: " + strComputerDomain
? "Computer Name: " + strComputerName
ENDIF
NEXT
 
Here's how to get a dump of all the properties:
Code:
cClass = "Win32_ComputerSystem"
oWMI   = GETOBJECT("winmgmts:")
oItems = oWMI.ExecQuery("select * from " + cClass)
CREATE CURSOR WMI_INFO (itemname c(100), property c(50), value c(200) )
FOR EACH oItem IN oItems
  FOR EACH oProperty IN oItem.Properties_
    INSERT INTO WMI_INFO VALUES ( oItem.Name, oProperty.Name,;
      ICASE( oProperty.IsArray         , "[Array]",;
             ISNULL(oProperty.Value)   , ".NULL.",;
             TRANSFORM(oProperty.Value) ) )
  NEXT oProperty
NEXT oItem
I get .NULL. returned for Workgroup, which would lead to a type mismatch, hence the check using ISNULL()

Your problem seems like the property doesnt exist, hence the code above to check what you are being returned.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top