So Windows 10 is here with its second build (9860) in its “Technical Preview”. Since I am an OSD guy, I like to make sure when a system is built all the drivers are there (even for my test machines and ad-hoc builds to “see if it works”). Usually this just entails adding some drivers and–for the most part–plug and play is nice enough to install everything for me. If you’re without MDT and/or SCCM or just like to have a USB installer ready for anything, you don’t have the luxury of a driver package and just want all the drivers to automatically be there when Windows installs.
This process is very common and really, this applies to Windows Vista (and up) but as I went to inject drivers to Windows 10 media from my Windows 8.1 machine I met an old-friend-of-an-error and figured this was worth sharing.
Get the Drivers
First thing’s first. Get the Drivers! For Windows 10, Microsoft has done a great job of letting Windows 7/8.1 drivers install (or attempt to) and maintain a large percentage of support. So, download all the drivers and put them into one directory. Make sure that any downloaded installers are extracted first to where you can see the inf, cat, and sys files. I know Dell and HP both have self extracting executable for most drivers they offer out.
If you’re like me, you’ll have a huge hierarchy of Manufacturer> Model showcasing all the different models that you want to test on and support.
Create Your Media
Connect a USB Drive (USB 3.0 is better :)). We’ll need to format the disk…This will remove all of the files so make sure to backup anything.
- Open an Administrative Command Prompt
- DiskPart <enter>
- List Disk <enter>
- Locate which disk is the usb drive. Easiest way is to tell by size.
- select disk # <enter> (# is the disk number from previous step)
- clean <enter>
- create partition primary <enter>
- select partition 1 <enter>
- format fs=fat32 quick <enter>
- active <enter>
- assign <enter>
- exit <enter>
Now you have a clean and fresh USB drive to use.
Extract the Install Files
With Windows 8+ you can just right-click and select “Mount” on the iso. Copy all of the files to the USB drive.
With Windows 7, you’ll need a program like 7-zip. Open the ISO, and extract all files to the USB drive.
Mount the WIM
There are two WIM’s in your Windows Installer that we’re concerned about: <InstallRoot>\sources\boot.wim and <InstallRoot>\sources\install.wim.
- The Boot.wim is what gets loaded when you boot to your install media. This is a WinPE image used to apply an OS–MDT/SCCM people will be very familiar with the boot media concept.
- The install.wim file is the actual sysprepped OS Installation that will get applied to your hard drive. If you mounted this, it will look just like your C drive: Program Files, Windows, Users, etc…
So really we now dive to 2 scenarios:
- When you boot to your media, your hard drive (or other device) is not recognized.
- When Windows is installed, drivers are missing
Scenario 1 relates to your boot media, scenario 2 relates to the install.wim. A rule of thumb is that your boot.wim only needs essential drivers; eg: storage and network. In this scenario, we’re only concerned about storage, since we’re using USB as our source media. Really though, both processes are the same.
- Open an Administrative Command prompt.
- Create a directory to mount the WIM file (mkdir c:\mount)
- Mount the wim:
dism /mount-wim /wimfile:%PathToWimFile% /Index:1 /mountdir:%ImageMountDir%
Add in the Drivers:
To add the drivers we’ll need to point the command to the folder of drivers we created above.
REMEMBER: only add storage and network to boot.wim. Anything more is just silly.
If you have you install.wim mounted you can point to the top folder that contains all the drivers for your model. Example: c:\drivers\hp\EliteBook800SeriesG1
Add the drivers:
dism /image:%ImageMountDirFromAbove% /add-driver /driver:%PathToDriversFolder% /recurse /forceunsigned
The recurse option will check all sub folders. the forceunsigned will allow unsigned drivers to be added.
On Windows 8.1 while mounting my Windows 10 install.wim i was greeted with an error:
Deployment Image Servicing and Management tool Version: 6.3.9600.17031 Error: 50 To service this Windows image requires the latest version of the DISM. See http://go.microsoft.com/fwlink/?LinkId=293395 to find the latest version of DISM, and http://go.microsoft.com/fwlink/?LinkId=293394 to learn how to install the latest version of DISM from the ADK on your computer. The DISM log file can be found at C:\Windows\Logs\DISM\dism.log
We could look at the dism log if we wanted but to me this error is rather self-explanatory. Essentially this is saying that the OS i have mounted is newer than the dism tool i’m using. Dism version: 6.3.9600.17031…Windows 8.1 OS Version is 6.3.9600 (see what they did there?). Think of it this way: Each version supports the corresponding Windows release plus older (Backwards compatible). It cannot work with a newer version since older version doesn’t know what newer version is.
The fix for this is to use the DISM command included in the Windows setup disk. Rerun the dism command above but this time, we’ll need to use the full path to the Windows 10 media:
%PathToWindowsInstallMedia%\Sources\dism.exe /image:%ImageMountDirFromAbove% /add-driver /driver:%PathToDriversFolder% /recurse /forceunsigned
And voila…now we have drivers added.
Save the Changes
Last thing is to commit the changes we made:
%PathToWindowsInstallMedia%\Sources\dism.exe /unmount-wim /mountdir:%ImageMountedDir% /commit
Again, this process will really apply to any version of Windows where you’d like to inject drivers within your media!