Difference between revisions of "Identify Client Form Factor"
(→Identify Chassis Simple) |
(→Identify Chassis Full) |
||
Line 130: | Line 130: | ||
strComputer = "." | strComputer = "." | ||
const HKEY_LOCAL_MACHINE = &H80000002 | const HKEY_LOCAL_MACHINE = &H80000002 | ||
− | strKeyPath = " | + | strKeyPath = "System\CurrentControlSet\Control\Session Manager\Environment" |
strValueName = "ChassisType" | strValueName = "ChassisType" | ||
strChassisValue = "" | strChassisValue = "" |
Revision as of 22:03, 21 February 2010
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.
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.
You will then need to use logical conditions to determine if an application install package targets a specific platform (laptop or desktop for example). Remember that logical conditions are counter-intuitive, if you want to install an application on a specific platform you check for what your target platform isn't.
For example:
<check type="logical" condition="or">
<check type="uninstall" condition="exists" path="SonicWALL SSL-VPN NetExtender" />
<check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\CHASSISTYPE" value="Desktop"/>
<check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\CHASSISTYPE" value="Other"/>
<check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\CHASSISTYPE" value="Unknown"/>
</check>
Of course be sure to modify the xml and vbs below to your needs.
Check Chassis Type
<?xml version="1.0" encoding="UTF-8"?>
<packages>
<package
id='chassistype'
name='ChassisType'
revision='1'
priority='999'
execute='once'
reboot='false'>
<check type="logical" condition="or">
<check type="uninstall" condition="exists" path="SonicWALL SSL-VPN NetExtender" />
<check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\CHASSISTYPE" value="Desktop"/>
<check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\CHASSISTYPE" value="Other"/>
<check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\CHASSISTYPE" value="Unknown"/>
</check>
<install cmd='cscript //B "%SOFTWARE%\system\identify_chassis_simple.vbs"' />
<upgrade cmd='cscript //B "%SOFTWARE%\system\identify_chassis_simple.vbs"' />
<remove cmd='REG DELETE HKLM\Software\xxxxx\wpkg\ /v ChassisType /f' />
</package>
</packages>
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).
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.
Identify Chassis Simple
strComputer = "."
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "System\CurrentControlSet\Control\Session Manager\Environment"
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 = "Other"
Case 12
strChassisValue = "Other"
Case 13
strChassisValue = "Desktop"
Case 14
strChassisValue = "Laptop"
Case 15
strChassisValue = "Desktop"
Case 16
strChassisValue = "Desktop"
Case 17
strChassisValue = "Desktop"
Case 18
strChassisValue = "Other"
Case 19
strChassisValue = "Other"
Case 20
strChassisValue = "Other"
Case 21
strChassisValue = "Other"
Case 22
strChassisValue = "Other"
Case 23
strChassisValue = "Other"
Case 24
strChassisValue = "Desktop"
Case Else
strChassisValue = "Unknown"
End Select
Next
Next
RegResult = objReg.SetStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strChassisValue)
Identify Chassis Full
strComputer = "."
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "System\CurrentControlSet\Control\Session Manager\Environment"
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)