Share This Post

Determine Chassis Type VB Script

Isn’t there a simple script to determine whether a computer is a laptop or desktop during OSD imaging without having to install MDT or use another utility? Now there is. JoeSaysChassis.vbs is a short script I wrote that will simply run and populate set these sequence variables to TRUE: JoeSaysDesktop and JoeSaysLaptop

This functionality is already built into Jason Sandys’ OSD App Tree 2.6 with the variables LaptopThisIs,DesktopThisIs and ServerThisIs, in case you already happen to be using that in your task sequence. However recently I had to create a zero touch deployment where applications had to be specifically installed by individual installation steps, rather than the install multiple applications task.

 

‘ J. Clarke 11/2/2011
‘ This script will grab the ChassisTypes property from WMI the Win32_SystemEnclousre class and populate corresponding task sequence variables.
‘ It will set task sequence variable JoeSaysLaptop = TRUE if it’s a laptop, and task sequence variable JoeSaysDesktop = TRUE if it’s a desktop.

‘ If you try to test this outside of a task sequence it will fail because it cannot create the SMS.TSEnvironment object.
‘ You must disable that to test outside.

On Error Resume Next

set env = CreateObject("Microsoft.SMS.TSEnvironment")

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array(".")
For Each strComputer In arrComputers

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_SystemEnclosure", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
      strChassisTypes = Join(objItem.ChassisTypes, ",")
         varChassisType = strChassisTypes
   Next
Next

HOORAY = "TRUE"

Select Case varChassisType
‘ Check
http://msdn.microsoft.com/en-us/library/Aa394474 for updates on Chassis type numbers

Case "8","9","10","11","14"
    env("JoeSaysLaptop") = HOORAY
   
Case "3","4","5","6","7","13","15","16"
    env("JoeSaysDesktop") = HOORAY
   
End Select

Share This Post

Leave a Reply