12 November 2011

Configuring BIOS Settings during the SCCM/MDT Imaging Process

You want to set the BIOS settings during an imaging process, but you can't get it correctly sequenced into the task sequencing. The BIOS can be set in the task sequencing process, but it can only function correctly after the image has been laid down; post-image process or later. This causes an issue for such tasks as setting the SATA mode to either AHCI or ATA. Once the image has been laid down, these cannot be set, otherwise the OS will blue screen upon reboot. In order to work around this, the boot WIM file, which loads the initial MDT screen, needs to be modified to include the Dell CCTK, inject HAPI drivers, and modify the unattend.xml file. The Dell CCTK is a command line utility that will set the BIOS settings. The HAPI drivers provide the hooks required by the CCTK to function properly. Finally, the unattend.xml file needs to be modified in order to load the HAPI drivers into memory and then execute the CCTK, which sets the BIOS settings, before executing the Litetouch.wsh. You can download the script from below.

NOTE: When using the CCTK, it is best to create a master ini data file for CCTK to read from for all of the model PCs you currently have, including both laptops and desktops. It does not matter if you have settings in there that a system does not have. It will skip over the settings that do not exist. The CCTK Options below is documentation provided by Dell of all the available CCTK options to add to your ini file.

NOTE: This has only been used on Dell systems at the firm I work for. We have 35 different models that we manage. I cannot guarantee the CCTK command and drivers will function correctly on any other system, other than a Dell.

Here are links to all of the CCTK BIOS options, multiplatform.ini file, and the script I wrote:



 '*******************************************************************************   
 '      Program: Install.vbs   
 '       Author: Mick Pletcher   
 '         Date:   
 '     Modified:   
 '   
 '      Program:   
 '      Version:   
 '  Description: This will do the following to the MDT/SCCM generated WIM files:   
 '        inject the Dell CCTK, inject the HAPI drivers, and modify the   
 '        unattend.xml file.   
 '
 ' Requirements: Microsoft WAIK, location for the locally stored WinPE files   
 '        (WinPEDIR Global Variable), MDT Server (I have 2 servers   
 '        MDT01 and MDT02), designation of architecture, and Dell CCTK.   
 '        NOTE: This script has been created to automate the update process   
 '        on a Windows 7 64-bit PC, therefor the directory locations of   
 '        the CCTK files will differ for an x86 machine.   
 '*******************************************************************************   
 Option Explicit  
 
 REM Define Constants   
 CONST TempFolder  = "c:\temp\"   
 CONST LogFolderName = "CCTK"   
 CONST MDT01     = "MDT01"   
 CONST MDT02     = "MDT02"   
 CONST WinPEDIR   = "c:\winpe\"   
 CONST x64      = "x64"   
 CONST x86      = "x86"   

 REM Define Global Variables   
 DIM LogFolder   : LogFolder    = TempFolder & LogFolderName & "\"   
 DIM RelativePath : Set RelativePath = Nothing   

 DefineRelativePath()   
 REM Refresh Local WIM Files from MDT Servers   
   DeleteLocalWIMFiles()   
   CopyWIMFiles( MDT01 )   
   RenameWIMFiles( MDT01 )   
   CopyWIMFiles( MDT02 )   
   RenameWIMFiles( MDT02 )   
 REM Process Local x86 file for MDT01   
   MountWIM MDT01,x86   
   AddWMI(x86)   
   CopyHAPIFiles( x86 )   
   CopyCCTKFiles( x86 )   
   EditUnattend( x86 )   
   DismountWIM()   
 REM Process Local x64 File for MDT01   
   MountWIM MDT01,x64   
   AddWMI(x64)   
   CopyHAPIFiles( x64 )   
   CopyCCTKFiles( x64 )   
   EditUnattend( x64 )   
   DismountWIM()   
 REM Process Local x86 File for MDT02   
   MountWIM MDT02,x86   
   AddWMI(x86)   
   CopyHAPIFiles( x86 )   
   CopyCCTKFiles( x86 )   
   EditUnattend( x86 )   
   DismountWIM()   
 REM Process Local x64 File for MDT02   
   MountWIM MDT02,x64   
   AddWMI(x64)   
   CopyHAPIFiles( x64 )   
   CopyCCTKFiles( x64 )   
   EditUnattend( x64 )   
   DismountWIM()   
 Complete()   
 GlobalVariableCleanup()   

 '*******************************************************************************   
 '*******************************************************************************   

 Sub DefineRelativePath()   

   REM Get File Name with full relative path   
   RelativePath = WScript.ScriptFullName   
   REM Remove file name, leaving relative path only   
   RelativePath = Left(RelativePath, InStrRev(RelativePath, "\")) 

 End Sub   

 '*******************************************************************************   

 Sub DeleteLocalWIMFiles()   

   REM Define Local Objects   
   DIM FSO    : Set FSO    = CreateObject("Scripting.FileSystemObject")   
   DIM oShell : SET oShell = CreateObject("Wscript.Shell")   

   REM Define Local Variables   
   DIM Parameters : Parameters = "/F /Q"   
   DIM sCMD_1 : sCMD_1 = "%COMSPEC% /c del " & RelativePath & "*MDT01.wim"   
   DIM sCMD_2 : sCMD_2 = "%COMSPEC% /c del " & RelativePath & "*MDT02.wim"   
   DIM sCMD_3 : sCMD_3 = "%COMSPEC% /c del " & RelativePath & "generic*.wim"   

   oShell.Run sCMD_1 & Parameters, 1, True   
   oShell.Run sCMD_2 & Parameters, 1, True   
   oShell.Run sCMD_3 & Parameters, 1, True   

   REM Cleanup Local Variables   
   Set sCMD_1     = Nothing   
   Set sCMD_2     = Nothing   
   Set sCMD_3     = Nothing   
   Set FSO        = Nothing   
   Set oShell     = Nothing   
   Set Parameters = Nothing   

 End Sub   

 '*******************************************************************************   

 Function CopyWIMFiles(Server)   

   REM Define Local Objects   
   DIM oShell : SET oShell = CreateObject("Wscript.Shell")   

   REM Define Local Variables   
   DIM Source      : Source      = "\\" & Server & "\DeploymentShare\Boot"   
   DIM Destination : Destination = "c:\winpe"   
   DIM Parameters  : Parameters  = "*.wim /eta /r:1 /w:0"   
   DIM Command01   : Command01   = "robocopy" & Chr(32) & Source & Chr(32) & Destination & Chr(32) & Parameters   

   oShell.Run Command01, 1, True  
 
   REM Cleanup Local Variables   
   Set Command01   = Nothing   
   Set Destination = Nothing   
   Set oShell      = Nothing   
   Set Parameters  = Nothing   
   Set Source      = Nothing   

 End Function   

 '*******************************************************************************   

 Function RenameWIMFiles(Server)   

   REM Define Local Objects   
   DIM FSO  : Set FSO  = CreateObject("Scripting.FileSystemObject")   

   REM Define Local Variables   
   DIM Source_x86 : Source_x86 = RelativePath & "LiteTouchPE_x86.wim"   
   DIM Source_x64 : Source_x64 = RelativePath & "LiteTouchPE_x64.wim"   
   DIM Dest_x86  : Dest_x86  = RelativePath & "LiteTouchPE_x86_" & Server & ".wim"   
   DIM Dest_x64  : Dest_x64  = RelativePath & "LiteTouchPE_x64_" & Server & ".wim"   

   If FSO.FileExists(Source_x86) then   
     If NOT FSO.FileExists(Dest_x86) then   
       FSO.MoveFile Source_x86, Dest_x86   
     End If   
   End If   
   If FSO.FileExists(Source_x64) then   
     If NOT FSO.FileExists(Dest_x64) then   
       FSO.MoveFile Source_x64, Dest_x64   
     End If   
   End If   

   REM Cleanup Local Variables   
   Set Dest_x86   = Nothing   
   Set Dest_x64   = Nothing   
   Set FSO        = Nothing   
   Set Source_x86 = Nothing   
   Set Source_x64 = Nothing   

 End Function   

 '*******************************************************************************   

 Function MountWIM(Server,Architecture)   

   REM Define Local Objects   
   DIM oShell : SET oShell = CreateObject("Wscript.Shell")   

   REM Define Local Variables   
   DIM MountDIR  : MountDIR  = RelativePath & "Mount"   
   DIM WIMFile   : WIMFile  = RelativePath & "LiteTouchPE_" & Architecture & "_" & Server & ".wim"   
   DIM Command01 : Command01 = "DISM /Mount-Wim /WIMFile:" & WIMFile & Chr(32) & "/Index:1 /MountDIR:" & MountDIR
   
   oShell.Run Command01, 1, True   

   REM Cleanup Local Variables   
   Set Command01 = Nothing   
   Set MountDIR  = Nothing   
   Set oShell    = Nothing   
   Set WIMFile   = Nothing 
  
 End Function   

 '*******************************************************************************   

 Sub AddWMI(Architecture)   

   REM Define Local Objects   
   DIM oShell : SET oShell = CreateObject("Wscript.Shell")   

   REM Define Local Variables   
   DIM Image           : Image       = "/Image:" & RelativePath & "Mount"   
   DIM AddPackage      : AddPackage   = "/Add-Package"   
   DIM PackagePath     : Set PackagePath = Nothing   
   DIM PackagePath_x86 : PackagePath_x86 = "/PackagePath:" & Chr(34) &_   
                       "C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-wmi.cab" & Chr(34)   
   DIM PackagePath_x64 : PackagePath_x64 = "/PackagePath:" & Chr(34) &_   
                       "C:\Program Files\Windows AIK\Tools\PETools\amd64\WinPE_FPs\winpe-wmi.cab" & Chr(34)   
   DIM Command01       : Set Command01  = Nothing   

   If Architecture = "x86" Then   
     PackagePath = PackagePath_x86   
   Else   
     PackagePath = PackagePath_x64   
   End If   
   Command01 = "DISM" & Chr(32) & Image & Chr(32) & AddPackage & Chr(32) & PackagePath   
   oShell.Run Command01, 1, True   

   REM Cleanup Local Variables   
   Set AddPackage      = Nothing   
   Set Command01       = Nothing   
   Set Image           = Nothing   
   Set oShell          = Nothing   
   Set PackagePath     = Nothing   
   Set PackagePath_x86 = Nothing   
   Set PackagePath_x64 = Nothing   

 End Sub   

 '*******************************************************************************   

 Sub CreateFolderStructure(Architecture)   

   REM Define Local Objects   
   DIM FSO    : Set FSO    = CreateObject("Scripting.FileSystemObject")   
   DIM oShell : Set oShell = CreateObject("Wscript.Shell")   

   REM Define Local Variables   
   DIM Command01     : Set Command01 = Nothing   
   DIM Directory     : Set Directory = Nothing   
   DIM Directory_x86 : Directory_x86 = RelativePath & "Mount\CCTK\x86\HAPI"   
   DIM Directory_x64 : Directory_x64 = RelativePath & "Mount\CCTK\x86_64\HAPI"   

   If Architecture = "x86" Then   
     Directory = Directory_x86   
   Else   
     Directory = Directory_x64   
   End If   
   If NOT FSO.FolderExists(Directory) then   
     FSO.CreateFolder(Directory)   
   End If   

   REM Cleanup Local Variables   
   Set Command01     = Nothing   
   Set Directory     = Nothing   
   Set Directory_x86 = Nothing   
   Set Directory_x64 = Nothing   
   Set FSO           = Nothing   
   Set oShell        = Nothing   

 End Sub   

 '*******************************************************************************   

 Sub CopyHAPIFiles(Architecture)   

   REM Define Local Objects   
   DIM FSO    : Set FSO    = CreateObject("Scripting.FileSystemObject")   
   DIM oShell : SET oShell = CreateObject("Wscript.Shell")   

   REM Define Local Variables   
   DIM sCMD_1     : Set sCMD_1 = Nothing   
   DIM sCMD_2     : Set sCMD_2 = Nothing   
   DIM Source     : Set Source = Nothing   
   DIM Source_x86 : Source_x86 = "C:\Program Files (x86)\Dell\CCTK\X86\HAPI\*.*"   
   DIM Source_x64 : Source_x64 = "C:\Program Files (x86)\Dell\CCTK\X86_64\HAPI\*.*"   
   DIM Dest       : Set Dest   = Nothing   
   DIM Dest_x86   : Dest_x86   = RelativePath & "mount\CCTK\x86\HAPI"   
   DIM Dest_x64   : Dest_x64   = RelativePath & "mount\CCTK\x86_64\HAPI"   

   If Architecture = "x86" Then   
     Source = Source_x86   
     Dest  = Dest_x86   
   Else   
     Source = Source_x64   
     Dest  = Dest_x64   
   End If   
   sCMD_1 = "%COMSPEC% /c mkdir " & Dest   
   If NOT FSO.FolderExists(Dest) then   
     oShell.Run sCMD_1, 1, True   
   End If   
   sCMD_2 = "%COMSPEC% /c copy " & Chr(34) & Source & Chr(34) & Chr(32) & Dest & Chr(32) & "/V /Y"   
 '  If FSO.FolderExists(Source) then   
     oShell.Run sCMD_2, 1, True   
 '  End If   

   REM Cleanup Local Variables   
   Set Dest       = Nothing   
   Set Dest_x86   = Nothing   
   Set Dest_x64   = Nothing   
   Set FSO        = Nothing   
   Set oShell     = Nothing   
   Set sCMD_1     = Nothing   
   Set sCMD_2     = Nothing   
   Set Source     = Nothing   
   Set Source_x86 = Nothing   
   Set Source_x64 = Nothing 
  
 End Sub   

 '*******************************************************************************   

 Sub CopyCCTKFiles(Architecture)   

   REM Define Local Objects   
   DIM FSO : Set FSO = CreateObject("Scripting.FileSystemObject")   

   REM Define Local Variables   
   DIM CCTKFile   : CCTKFile  = "cctk.exe"   
   DIM MXMLFile   : MXMLFile  = "mxml1.dll"   
   DIM INIFile    : INIFile  = "multiplatform.ini"   
   DIM PCIFile    : PCIFile  = "pci.ids"   
   DIM NetSource  : NetSource = "\\global.gsp\data\clients\na_clients\Dell\BIOS\"   
   DIM Source     : Set Source = Nothing   
   DIM Source_x86 : Source_x86 = "C:\Program Files (x86)\Dell\CCTK\X86\"   
   DIM Source_x64 : Source_x64 = "C:\Program Files (x86)\Dell\CCTK\X86_64\"   
   DIM Dest       : Set Dest  = Nothing   
   DIM Dest_x86   : Dest_x86  = RelativePath & "mount\CCTK\x86\"   
   DIM Dest_x64   : Dest_x64  = RelativePath & "mount\CCTK\x86_64\"   

   If Architecture = "x86" Then   
     Source = Source_x86   
     Dest  = Dest_x86   
   Else   
     Source = Source_x64   
     Dest  = Dest_x64   
   End If   
   If NOT FSO.FolderExists(Dest) then   
     FSO.CreateFolder(Dest)   
   End If   
   If FSO.FolderExists(Source) then   
     FSO.CopyFile Source & CCTKFile, Dest, 1   
   End If   
   If FSO.FolderExists(Source) then   
     FSO.CopyFile NetSource & INIFile, Dest, 1   
   End If   
   If FSO.FolderExists(Source) then   
     FSO.CopyFile Source & PCIFile, Dest, 1   
   End If   
   If FSO.FolderExists(Source) then   
     FSO.CopyFile Source & MXMLFile, Dest, 1   
   End If   

   REM Cleanup Local Variables   
   Set CCTKFile   = Nothing   
   Set INIFile    = Nothing   
   Set MXMLFile   = Nothing   
   Set PCIFile    = Nothing   
   Set Dest       = Nothing   
   Set Dest_x86   = Nothing   
   Set Dest_x64   = Nothing   
   Set FSO        = Nothing   
   Set Source     = Nothing   
   Set Source_x86 = Nothing   
   Set Source_x64 = Nothing   

 End Sub   

 '*******************************************************************************   

 Sub EditUnattend(Architecture)   

 REM Define Local Constants   
 CONST ForReading = 1   
 CONST ForWriting = 2   

 REM Define Local Objects   
 DIM File    : File    = "C:\winpe\mount\unattend.xml"   
 DIM strOld1 : strOld1 = "<Order>1</Order>"   
 DIM strNew1 : strNew1 = "<Order>4</Order>"   
 DIM strOld2 : strOld2 = "<RunSynchronous>"   
 DIM strNew2 : strNew2 = "<RunSynchronous>" & Chr(10) &_   
                     "<RunSynchronousCommand wcm:action=" & Chr(34) & "add" & Chr(34) & ">" & Chr(10) &_   
                     "<Description>Map BIOS Drive</Description>" & Chr(10) &_   
                     "<Order>1</Order>" & Chr(10) &_   
                     "<Path>net use \\global.gsp\data\clients\na_clients\dell\bios /user:{username/password}</Path>" & Chr(10) &_   
                     "</RunSynchronousCommand>" & Chr(10) &_   
                     "<RunSynchronousCommand wcm:action=" & Chr(34) & "add" & Chr(34) & ">" & Chr(10) &_   
                     "<Description>Initiate HAPI</Description>" & Chr(10) &_   
                     "<Order>2</Order>" & Chr(10) &_   
                     "<Path>X:\CCTK\x86_64\HAPI\hapint -i -k C-C-T-K -p X:\CCTK\x86_64\HAPI\</Path>" & Chr(10) &_   
                     "</RunSynchronousCommand>" & Chr(10) &_   
                     "<RunSynchronousCommand wcm:action=" & Chr(34) & "add" & Chr(34) & ">" & Chr(10) &_   
                     "<Description>Set BIOS Settings</Description>" & Chr(10) &_   
                     "<Order>3</Order>" & Chr(10) &_   
                     "<Path>x:\CCTK\x86_64\cctk.exe -i \\global.gsp\data\clients\na_clients\Dell\BIOS\multiplatform.ini</Path>" & Chr(10) &_   
                     "</RunSynchronousCommand>"   
 DIM objFSO        : Set objFSO    = CreateObject("Scripting.FileSystemObject")   
 DIM objFile       : Set objFile    = objFSO.getFile(File)   
 DIM objTextStream : Set objTextStream = objFile.OpenAsTextStream(ForReading)   
 DIM strInclude    : strInclude    = objTextStream.ReadAll   

 objTextStream.Close   
 Set objTextStream = Nothing   
 If InStr(strInclude,strOld1) > 0 Then   
   strInclude = Replace(strInclude,strOld1,strNew1)   
   Set objTextStream = objFile.OpenAsTextStream(ForWriting)   
   objTextStream.Write strInclude   
   objTextSTream.Close   
   Set objTextStream = Nothing   
 End If   
 If InStr(strInclude,strOld2) > 0 Then   
   strInclude = Replace(strInclude,strOld2,strNew2)   
   Set objTextStream = objFile.OpenAsTextStream(ForWriting)   
   objTextStream.Write strInclude   
   objTextSTream.Close   
   Set objTextStream = Nothing   
 End If  
 
 REM Cleanup Local Variables   
 Set File          = Nothing   
 Set objFile       = Nothing   
 Set objFSO        = Nothing   
 Set objTextStream = Nothing   
 Set strInclude    = Nothing   
 Set strNew1       = Nothing   
 Set strNew2       = Nothing   
 Set strOld1       = Nothing   
 Set strOld2       = Nothing   

 End Sub   

 '*******************************************************************************   

 Sub DismountWIM()   

   REM Define Local Objects   
   DIM oShell : SET oShell = CreateObject("Wscript.Shell")   

   REM Define Local Variables   
   DIM MountDIR  : MountDIR  = RelativePath & "Mount"   
   DIM Command01 : Command01 = "DISM /Unmount-WIM /MountDir:" & MountDIR & Chr(32) & "/commit"   

   oShell.Run Command01, 1, True   

   REM Cleanup Local Variables   
   Set Command01 = Nothing   
   Set MountDIR  = Nothing   
   Set oShell    = Nothing   

 End Sub   

 '*******************************************************************************   

 Sub Complete()   

   MsgBox "Process Complete"   

 End Sub   

 '*******************************************************************************   

 Sub GlobalVariableCleanup()   

   Set LogFolder    = Nothing   
   Set RelativePath = Nothing   

 End Sub  


Multiplatform.ini File.

NOTE: The semi-colon in front of the items comments them out
 [cctk]  
 acpower=last  
 ;agpslot=enable  
 amblightsen=enable  
 ;autoon=disable  
 ;autoonhr=0  
 ;autoonmn=0  
 bltinfloppy=disable  
 ;bltinpntdevice=enable  
 ;bluetoothdevice=enable  
 bootorder=+hdd,+cdrom,+usbcdrom,+usbdev,+embnic,-floppy  
 ;camera=enable  
 ;cellularradio=enable  
 chasintrusion=disable  
 ;clearsel=yes  
 ;dbpm=enable  
 embnic1=on  
 embsataraid=ahci  
 ;embscsi1=off  
 ;embscsi2=off  
 ;embsdcard=on  
 ;embvideoctrl=enable  
 ;energystarlogo=enable  
 ;esataports=enable  
 ;expresscard=enable  
 expresscharge=enable  
 fastboot=minimal  
 floppy=usb  
 ;forcepxe=disable  
 hddacousticmode=performance  
 ;hddprotection=on  
 ;hdfreefallprotect=enable  
 hotdock=enable  
 ;htkeywxanradio=enable  
 ;idecdrom=auto  
 ;instanton=enable  
 ;integratedaudio=enable  
 ;integratedsas=disable  
 ;internalminipci=enable  
 ;interwirelessuwb=enable  
 ;ioat=enable  
 ;keyboardclick=disable  
 keyboardillumination=auto  
 ;keypad=enabledbynumlock  
 ;limitcpuidvalue=off  
 logicproc=enable  
 ;lowpowers5=disable  
 ;lpt=lpt1  
 ;mediacard=enable  
 ;mediacardand1394=enable  
 ;memtest=disable  
 ;microphone=enable  
 ;minicardssd=enable  
 ;mobilepowermgmt=enable  
 ;mouse=on  
 multicpucore=enable  
 ;onboard1394=enable  
 ;onboardmodem=enable  
 onreader=disable  
 ;opticaldrivectrl=enable  
 ;osmode=disable  
 ;pccardand1394=enable  
 ;pcisata=enable  
 ;pcislots=enable  
 ;postf12key=enable  
 ;postf2key=enable  
 ;postmebxkey=on  
 ;powerbutton=enable  
 ;radiotransmission=enable  
 ;rearsingleusb=on  
 ;rptkeyerr=enable  
 ;sata0=auto  
 ;smartcardreader=enable  
 ;smartcpu=enable  
 smarterrors=enable  
 ;speaker=on  
 speedstep=enable  
 ;splashscreen=disable  
 ;standbystate=s3  
 ;surroundview=enable  
 ;sysbatcharger=enable  
 ;sysfanspeed=noisereduce  
 ;tpm=off  
 ;trustexecution=on  
 ;turbomode=enable  
 ;usb=on  
 ;usb30=enable  
 ;usbctl=enable  
 ;usbports=enable  
 ;usbportsexternal=enable  
 ;usbportsfront=enable  
 ;usbreardual=on  
 ;usbrearquad=on  
 ;videoexpsn=enable  
 ;virtualappliance=on  
 virtualization=enable  
 vtfordirectio=on  
 wakeonlan=lanorwlan  
 ;wificatcherchanges=permit  
 ;wifilocator=enable  
 ;wirelessadapter=enable  
 ;wirelesslan=enable  
 ;wirelessuwb=enable  
 ;wirelesswitchbluetoothctrl=enable  
 ;wirelesswitchcellularctrl=enable  
 ;wirelesswitchnlanctrl=enable  

4 comments:

  1. Can you post the multiplatform.ini file with the settings you apply to all your dell?

    ReplyDelete
  2. Mick,

    Would you have time for a quick phone call or email char offline?

    ReplyDelete
  3. Sure, just message from from me about.me page and we can exchange phone numbers there: http://about.me/pletchermick

    ReplyDelete
  4. Sorry Mick - Failed to read the description of script before sending last message - DOH!!

    ReplyDelete