WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WMI
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Determine Machine Type


Question:

I'm looking for a way to determine through WMI what type of machine you are on (i.e. a desktop, laptop or tablet). Is there an easy way to do that? I'm poking through the WMI classes, but not having much luck....

I found the MS info on a WMI class - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_systemenclosure.asp - but I'm not sure how one would enumerate an array in VB. ANy ideas?? it's uint16 ChassisTypes[];

Answer:

Winbatch Version: 2005G -- Script By Jay Alverson




;   here's a quickie-script...

#DefineSubRoutine GetChType()

   Select @TRUE
      Case strChassisType == 1
          pctype ="Other"
          Break
      Case strChassisType == 2
          pctype ="Unknown"
          Break
      Case strChassisType == 3
          pctype ="Desktop"
          Break
      Case strChassisType == 4
          pctype ="Low Profile Desktop"
          Break
      Case strChassisType == 5
          pctype ="Pizza Box "
          Break
      Case strChassisType == 6
          pctype ="Mini Tower"
          Break
      Case strChassisType == 7
          pctype ="Tower"
          Break
      Case strChassisType == 8
          pctype ="Portable"
          Break
      Case strChassisType == 9
          pctype ="Laptop"
          Break
      Case strChassisType == 10
          pctype ="Notebook"
          Break
      Case strChassisType == 11
          pctype ="Hand Held"
          Break
      Case strChassisType == 12
          pctype ="Docking Station"
          Break
      Case strChassisType == 13
          pctype ="All in One"
          Break
      Case strChassisType == 14
          pctype ="Sub Notebook"
          Break
      Case strChassisType == 15
          pctype ="Space-Saving"
          Break
      Case strChassisType == 16
          pctype ="Lunch Box "
          Break
      Case strChassisType == 17
          pctype ="Main System Chassis"
          Break
      Case strChassisType == 18
          pctype ="Expansion Chassis"
          Break
      Case strChassisType == 19
          pctype ="SubChassis"
          Break
      Case strChassisType == 20
          pctype ="Bus Expansion Chassis"
          Break
      Case strChassisType == 21
          pctype ="Peripheral Chassis"
          Break
      Case strChassisType == 22
          pctype ="Storage Chassis"
          Break
      Case strChassisType == 23
          pctype ="Rack Mount Chassis"
          Break
      Case strChassisType == 24
          pctype ="Sealed-Case PC"
          Break
   EndSelect
   Return(pctype)
#EndSubRoutine

objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

colChassis = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")

ForEach objChassis In colChassis
   ForEach strChassisType In objChassis.ChassisTypes
   Message(strChassisType, GetChType())
   Next
Next

Exit


Article ID:   W17314
File Created: 2007:07:03:14:29:28
Last Updated: 2007:07:03:14:29:28