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 Laptop or Destop System Enclosure


Had a need to determine if a machine is a laptop or not. This can be used to grab the enclosure type of a machine from WMI. List included. It could be improved by reading the entire "ChassisTypes" array, but seems to work fine for my immediate needs.


Locator = ObjectOpen("WbemScripting.SWbemLocator")
Service = Locator.ConnectServer()
Security = Service.Security_
Security.ImpersonationLevel = 3
EnclosureSet = Service.InstancesOf("Win32_SystemEnclosure")
Enum = ObjectCollectionOpen(EnclosureSet)

While 1
  Enclosure = ObjectCollectionNext(Enum)
  If Enclosure == 0 Then Break
  ChassisType=(Enclosure.ChassisTypes(0)) ;just grabbing the first value in the array
  ObjectClose(Enclosure)
EndWhile

ObjectCollectionClose(Enum)
ObjectClose(EnclosureSet)

If ChassisType==8 || ChassisType==9 || ChassisType==10 
	Message(ChassisType,"Is a Laptop")
Else
	Message(ChassisType,"Is not a Laptop")
EndIf

;Reference:
;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_systemenclosure.asp

;Value Meaning 
;1 Other 
;2 Unknown 
;3 Desktop 
;4 Low Profile Desktop 
;5 Pizza Box  
;6 Mini Tower 
;7 Tower 
;8 Portable 
;9 Laptop 
;10 Notebook 
;11 Hand Held 
;12 Docking Station 
;13 All in One 
;14 Sub Notebook 
;15 Space-Saving 
;16 Lunch Box  
;17 Main System Chassis 
;18 Expansion Chassis 
;19 SubChassis 
;20 Bus Expansion Chassis 
;21 Peripheral Chassis 
;22 Storage Chassis 
;23 Rack Mount Chassis 
;24 Sealed-Case PC 

Article ID:   W16271
File Created: 2004:03:30:15:43:42
Last Updated: 2004:03:30:15:43:42