Sunday, January 4, 2009

How To Determine if a Computer is a Laptop or a Desktop Machine or Docking Station or ..?

Vbscript courtesy of:
http://www.novell.com/coolsolutions/feature/15533.html
By Greg DeBrun

---------- START SCRIPT -------------
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\DOC's Computer Type"
objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colChassis = objWMIService.ExecQuery _
("Select * from Win32_SystemEnclosure")
For Each objChassis in colChassis
For Each strChassisType in objChassis.ChassisTypes
Select Case strChassisType
Case 1
strEntryName = "PCTYPE"
strValue = "Other"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 2
strEntryName = "PCTYPE"
strValue = "Unknown"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 3
strEntryName = "PCTYPE"
strValue = "Desktop"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 4
strEntryName = "PCTYPE"
strValue = "Low Profile Desktop"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 5
strEntryName = "PCTYPE"
strValue = "Pizza Box"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 6
strEntryName = "PCTYPE"
strValue = "Mini Tower"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 7
strEntryName = "PCTYPE"
strValue = "Tower"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 8
strEntryName = "PCTYPE"
strValue = "Portable"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 9
strEntryName = "PCTYPE"
strValue = "Laptop"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 10
strEntryName = "PCTYPE"
strValue = "Notebook"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 11
strEntryName = "PCTYPE"
strValue = "Handheld"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 12
strEntryName = "PCTYPE"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 14
strEntryName = "PCTYPE"
strValue = "Sub-Notebook"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 15
strEntryName = "PCTYPE"
strValue = "Space Saving"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 16
strEntryName = "PCTYPE"
strValue = "Lunch Box"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 17
strEntryName = "PCTYPE"
strValue = "Main System Chassis"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 18
strEntryName = "PCTYPE"
strValue = "Expansion Chassis"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 19
strEntryName = "PCTYPE"
strValue = "Sub-Chassis"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 20
strEntryName = "PCTYPE"
strValue = "Bus Expansion Chassis"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 21
strEntryName = "PCTYPE"
strValue = "Peripheral Chassis"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 22
strEntryName = "PCTYPE"
strValue = "Storage Chassis"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 23
strEntryName = "PCTYPE"
strValue = "Rack Mount Chassis"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case 24
strEntryName = "PCTYPE"
strValue = "Sealed-Case PC"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
Case Else
strEntryName = "PCTYPE"
strValue = "Unknown"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
End Select
Next
Next
---------- END SCRIPT -------------

No comments: