There will be scenarios we face sometimes like need to identify the machine is desktop or laptop and proceed to install the software accordingly.
Here is the script to verify the system is a Desktop.
Solution
Dim strNameSpace
Dim oEnclosures, objChassis,strChassisType
strNameSpace = "\root\cimv2"
Set oEnclosures = GetObject("winmgmts:").InstancesOf("Win32_SystemEnclosure")
For Each objChassis In oEnclosures
For Each strChassisType In objChassis.ChassisTypes
Select Case strChassisType
Case "3" ' Desktop
Desktop = True
Case "4" ' Low Profile Desktop
Desktop = True
Case "5" ' Pizza Box
Desktop = True
Case "6" ' Mini Tower
Desktop = True
Case "7" ' Tower
Desktop = True
Case "15" ' Space-Saving
Desktop = True
Case "16" ' Lunch Box
Desktop = True
Case Else
Desktop = False
End Select
Next
Next
If Desktop = True Then
MsgBox "The machine is desktop"
Else
MsgBox "The machine is not a desktop"
End If
Set oEnclosures = Nothing
Set strChassisType = Nothing
Set objChassis = Nothing
Note: Modify the script based on your needs, suppose if you want to check the machine is a laptop or others.
'############################################################
'ChassisTypes 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
'Thus, the following Chassis Types are typical to:
'laptops: 8 , 9, 10, 11, 12, 14, 18, 21
'desktops: 3, 4, 5, 6, 7, 15, 16
'servers: 17,23
'#########################################################
Here is the script to verify the system is a Desktop.
Solution
Dim strNameSpace
Dim oEnclosures, objChassis,strChassisType
strNameSpace = "\root\cimv2"
Set oEnclosures = GetObject("winmgmts:").InstancesOf("Win32_SystemEnclosure")
For Each objChassis In oEnclosures
For Each strChassisType In objChassis.ChassisTypes
Select Case strChassisType
Case "3" ' Desktop
Desktop = True
Case "4" ' Low Profile Desktop
Desktop = True
Case "5" ' Pizza Box
Desktop = True
Case "6" ' Mini Tower
Desktop = True
Case "7" ' Tower
Desktop = True
Case "15" ' Space-Saving
Desktop = True
Case "16" ' Lunch Box
Desktop = True
Case Else
Desktop = False
End Select
Next
Next
If Desktop = True Then
MsgBox "The machine is desktop"
Else
MsgBox "The machine is not a desktop"
End If
Set oEnclosures = Nothing
Set strChassisType = Nothing
Set objChassis = Nothing
Note: Modify the script based on your needs, suppose if you want to check the machine is a laptop or others.
'############################################################
'ChassisTypes 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
'Thus, the following Chassis Types are typical to:
'laptops: 8 , 9, 10, 11, 12, 14, 18, 21
'desktops: 3, 4, 5, 6, 7, 15, 16
'servers: 17,23
'#########################################################
No comments:
Post a Comment