41
edits
Changes
New page: The following package identifies the client form factor and writes an entry into the Registry which can subsequently be read by other application install packages.<br> It relies on a vbs ...
The following package identifies the client form factor and writes an entry into the Registry which can subsequently be read by other application install packages.<br>
It relies on a vbs script which queries WMI to identify the hardware chassis type then writes the returned value to wherever you specify in the Registry.<br>
Of course be sure to modify the xml and vbs below to your needs.<br>
<source lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
<packages>
<package
id='chassistype'
name='ChassisType'
revision='1'
priority='999'
execute='once'
reboot='false'>
<check type='registry' condition='exists' path="HKLM\Software\xxxxx\wpkg\ChassisType" />
<install cmd='%COMSPEC% /c cscript //B "%SOFTWARE%\system\identify_chassis_simple.vbs"' />
<upgrade cmd='%COMSPEC% /c cscript //B "%SOFTWARE%\system\identify_chassis_simple.vbs"' />
<remove cmd='REG DELETE HKLM\Software\xxxxx\wpkg\ /v ChassisType /f' />
</package>
</packages>
</source>
<br>
Now I have two different versions of the vbs script, the '''identify_chassis_simple.vbs''' script writes "desktop" or "laptop" for a number of different chassis type return codes. The '''identify_chassis.vbs''' script at the bottom has a lot more chassis types if you need that granularity in your application installs (I don't).<br>
The most important fields to modify in the vbs below are strKeyPath and possibly strValueName to suite your environment and ensure it is the same as the checktype registry path.
<br>
===Identify Chassis Simple===
<source lang="vb">
strComputer = "."
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SOFTWARE\xxxxx\wpkg"
strValueName = "ChassisType"
strChassisValue = ""
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")
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
strChassisValue = "Other"
Case 2
strChassisValue = "Unknown"
Case 3
strChassisValue = "Desktop"
Case 4
strChassisValue = "Desktop"
Case 5
strChassisValue = "Desktop"
Case 6
strChassisValue = "Desktop"
Case 7
strChassisValue = "Desktop"
Case 8
strChassisValue = "Laptop"
Case 9
strChassisValue = "Laptop"
Case 10
strChassisValue = "Laptop"
Case 11
strChassisValue = "Handheld"
Case 12
strChassisValue = "Docking Station"
Case 13
strChassisValue = "Desktop"
Case 14
strChassisValue = "Laptop"
Case 15
strChassisValue = "Desktop"
Case 16
strChassisValue = "Desktop"
Case 17
strChassisValue = "Desktop"
Case 18
strChassisValue = "Expansion Chassis"
Case 19
strChassisValue = "Sub-Chassis"
Case 20
strChassisValue = "Bus Expansion Chassis"
Case 21
strChassisValue = "Peripheral Chassis"
Case 22
strChassisValue = "Storage Chassis"
Case 23
strChassisValue = "Rack Mount Chassis"
Case 24
strChassisValue = "Desktop"
Case Else
strChassisValue = "Unknown"
End Select
Next
Next
RegResult = objReg.SetStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strChassisValue)
</source>
<br>
===Identify Chassis Full===
<source lang="vb">
strComputer = "."
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SOFTWARE\xxxxx\wpkg"
strValueName = "ChassisType"
strChassisValue = ""
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")
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
strChassisValue = "Other"
Case 2
strChassisValue = "Unknown"
Case 3
strChassisValue = "Desktop"
Case 4
strChassisValue = "Low Profile Desktop"
Case 5
strChassisValue = "Pizza Box"
Case 6
strChassisValue = "Mini Tower"
Case 7
strChassisValue = "Tower"
Case 8
strChassisValue = "Portable"
Case 9
strChassisValue = "Laptop"
Case 10
strChassisValue = "Notebook"
Case 11
strChassisValue = "Handheld"
Case 12
strChassisValue = "Docking Station"
Case 13
strChassisValue = "All-in-One"
Case 14
strChassisValue = "Sub-Notebook"
Case 15
strChassisValue = "Space Saving"
Case 16
strChassisValue = "Lunch Box"
Case 17
strChassisValue = "Main System Chassis"
Case 18
strChassisValue = "Expansion Chassis"
Case 19
strChassisValue = "Sub-Chassis"
Case 20
strChassisValue = "Bus Expansion Chassis"
Case 21
strChassisValue = "Peripheral Chassis"
Case 22
strChassisValue = "Storage Chassis"
Case 23
strChassisValue = "Rack Mount Chassis"
Case 24
strChassisValue = "Sealed-Case PC"
Case Else
strChassisValue = "Unknown"
End Select
Next
Next
RegResult = objReg.SetStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strChassisValue)
</source>
It relies on a vbs script which queries WMI to identify the hardware chassis type then writes the returned value to wherever you specify in the Registry.<br>
Of course be sure to modify the xml and vbs below to your needs.<br>
<source lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
<packages>
<package
id='chassistype'
name='ChassisType'
revision='1'
priority='999'
execute='once'
reboot='false'>
<check type='registry' condition='exists' path="HKLM\Software\xxxxx\wpkg\ChassisType" />
<install cmd='%COMSPEC% /c cscript //B "%SOFTWARE%\system\identify_chassis_simple.vbs"' />
<upgrade cmd='%COMSPEC% /c cscript //B "%SOFTWARE%\system\identify_chassis_simple.vbs"' />
<remove cmd='REG DELETE HKLM\Software\xxxxx\wpkg\ /v ChassisType /f' />
</package>
</packages>
</source>
<br>
Now I have two different versions of the vbs script, the '''identify_chassis_simple.vbs''' script writes "desktop" or "laptop" for a number of different chassis type return codes. The '''identify_chassis.vbs''' script at the bottom has a lot more chassis types if you need that granularity in your application installs (I don't).<br>
The most important fields to modify in the vbs below are strKeyPath and possibly strValueName to suite your environment and ensure it is the same as the checktype registry path.
<br>
===Identify Chassis Simple===
<source lang="vb">
strComputer = "."
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SOFTWARE\xxxxx\wpkg"
strValueName = "ChassisType"
strChassisValue = ""
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")
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
strChassisValue = "Other"
Case 2
strChassisValue = "Unknown"
Case 3
strChassisValue = "Desktop"
Case 4
strChassisValue = "Desktop"
Case 5
strChassisValue = "Desktop"
Case 6
strChassisValue = "Desktop"
Case 7
strChassisValue = "Desktop"
Case 8
strChassisValue = "Laptop"
Case 9
strChassisValue = "Laptop"
Case 10
strChassisValue = "Laptop"
Case 11
strChassisValue = "Handheld"
Case 12
strChassisValue = "Docking Station"
Case 13
strChassisValue = "Desktop"
Case 14
strChassisValue = "Laptop"
Case 15
strChassisValue = "Desktop"
Case 16
strChassisValue = "Desktop"
Case 17
strChassisValue = "Desktop"
Case 18
strChassisValue = "Expansion Chassis"
Case 19
strChassisValue = "Sub-Chassis"
Case 20
strChassisValue = "Bus Expansion Chassis"
Case 21
strChassisValue = "Peripheral Chassis"
Case 22
strChassisValue = "Storage Chassis"
Case 23
strChassisValue = "Rack Mount Chassis"
Case 24
strChassisValue = "Desktop"
Case Else
strChassisValue = "Unknown"
End Select
Next
Next
RegResult = objReg.SetStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strChassisValue)
</source>
<br>
===Identify Chassis Full===
<source lang="vb">
strComputer = "."
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SOFTWARE\xxxxx\wpkg"
strValueName = "ChassisType"
strChassisValue = ""
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")
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
strChassisValue = "Other"
Case 2
strChassisValue = "Unknown"
Case 3
strChassisValue = "Desktop"
Case 4
strChassisValue = "Low Profile Desktop"
Case 5
strChassisValue = "Pizza Box"
Case 6
strChassisValue = "Mini Tower"
Case 7
strChassisValue = "Tower"
Case 8
strChassisValue = "Portable"
Case 9
strChassisValue = "Laptop"
Case 10
strChassisValue = "Notebook"
Case 11
strChassisValue = "Handheld"
Case 12
strChassisValue = "Docking Station"
Case 13
strChassisValue = "All-in-One"
Case 14
strChassisValue = "Sub-Notebook"
Case 15
strChassisValue = "Space Saving"
Case 16
strChassisValue = "Lunch Box"
Case 17
strChassisValue = "Main System Chassis"
Case 18
strChassisValue = "Expansion Chassis"
Case 19
strChassisValue = "Sub-Chassis"
Case 20
strChassisValue = "Bus Expansion Chassis"
Case 21
strChassisValue = "Peripheral Chassis"
Case 22
strChassisValue = "Storage Chassis"
Case 23
strChassisValue = "Rack Mount Chassis"
Case 24
strChassisValue = "Sealed-Case PC"
Case Else
strChassisValue = "Unknown"
End Select
Next
Next
RegResult = objReg.SetStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strChassisValue)
</source>