I’m currently reconfiguring my organization’s deployment server to use the DriverGroup001 variable instead of just using PnP matching for driver injection. We have had too many models interfering with each other. Bad drivers or just bad driver matches will lead to a BSoD or a buggy computer that requires more time troubleshooting or reimaging. The DriverGroup variable I’m setting points the Drivers to a folder for the operating system, a subfolder per manufacturer, and then a subfolder per model.
The manufacturer and model have to be exactly the same as what the deployment will see when it queries the %make% and %model% variables from the BIOS. I have previously shown how to get that information from a working computer using scripts and WMI but how do you get that information when you don’t have a running PC to run those scripts?
I created a WinPE LiveCD that I can boot from with the WMI query so I can get my deployment up and running quickly.
The first task is to install the Windows 7 OEM Preinstall Kit or Windows Automated Install Kit (AIK) for Windows 7. Both work but some paths in the commands will change for your version. I built my boot CD with Windows AIK.
Once your tool is installed, find it on the Start Menu and run the Windows AIK Deployment Command Line Tools as an administrator (elevated command prompt). Once the command prompt opens, run this command to copy the needed files to your working directory (can be anywhere):
copype.cmd x86 c:\winpe
The x86 indicates that I’m building the 32-bit architecture of the tool. I chose that for simplicity and compatibility. Your other options include amd64 and ia64.
With Windows 7, WinPE is at version 3.0. Version 2.0 used ‘peimg’ as a command line tool. With version 3, we use DISM or Deployment Image Servicing and Management. We mount the Windows image that was just copied over using this command:
dism /mount-wim /WimFile:C:\winpe\winpe.wim /index:1 /MountDir:C:\winpe\mount
The vanilla WinPE is pretty simplistic. We will need to install some additional packages to get WMI working. For each package, you have to install the language-neutral and then the language specific package. You can find the packages here: C:Program FilesWindows AIKToolsPEToolsx86WinPE_FPs
To add the WMI package, we run these commands:
DISM /Image:c:winpemount /Add-Package /PackagePath:"C:Program FilesWindows AIKToolsPEToolsx86WinPE_FPswinpe-wmi.cab"
DISM /Image:c:winpemount /Add-Package /PackagePath:"C:Program FilesWindows AIKToolsPEToolsx86WinPE_FPsen-uswinpe-wmi_en-us.cab"
Unfortunately just the WMI package is not enough to get it working. You will get an error like “class not registered” or “invalid class string” if you don’t have all the needed packages. I also added the scripting, MDAC, and HTA packages (both language neutral and language specific).
I wrote a little script to make it easier on myself and coworkers that might use this tool to script the WMI query with the WMIC command line tool.
WMIC computersystem get manufacturer
WMIC computersystem get model
pause
I saved the file as make_model.cmd and copied it to my mounted location under Windowssystem32 since that is where the WinPE command prompt starts up. To make it even easier, I copied those lines into the mounted WindowsSystem32Startnet.cmd file so the commands run first thing after the wininit command automatically.
Next, we’ll need to unmount and save the changes to the image running this command:
Dism /unmount-wim /mountdir:c:winpemount /commit
We copy the .wim file at the top of our file into our ISO folder.
copy c:\winpe\winpe.wim c:winpe\ISO\sources\boot.wim
Next, we turn that folder into a bootable .iso file using an included tool and .com file with this line:
Oscdimg -n -bC:\winpe\Etfs\boot.com C:\winpe\ISO C:\winpe\winpe.iso
Finally, we can burn that .iso file or test it in a VM to make sure it’s working. Now finding out the information I need is as easy as booting to a CD and jotting down the results from the script.
You can download the iso file that I created and extract with 7-zip.
A lot of this information was obtained from Microsoft TechNet articles but it wasn’t updated to WinPE 3.0 (it was using peimg instead of dism). Here is an updated article that helps with the general process of building a WinPE LiveCD.