Adding Surface drivers to Windows image

I recently had cause to reinstall Windows 10 onto a Surface Laptop 3 but ran into some problems, the keyboard/touchpad didn’t work!

I had created the Windows 10 installation USB drive using Microsoft’s installation media tool (https://www.microsoft.com/en-gb/software-download/windows10) Well, it turns out that the image created didn’t include the drivers required to support the keyboard and trackpad of the Surface Laptop! Now I suppose I could have just plugged one in, but as I needed the single USB A port for my USB drive I couldn’t without buying an adapter.

I therefore set about updating the USB installation drive with the drivers needed. The first Step was to download the latest Drivers and Firmware package, I used the links found at  https://docs.microsoft.com/en-us/surface/enable-surface-keyboard-for-windows-pe-deployment#add-keyboard-drivers-to-the-selection-profile helpfully the page confirms which of the drivers are actually needed.

The above link describes how to extract the files, for example:

Msiexec.exe /a <MSI File Name>.msi targetdir=c:\surface_laptop /qn

The rest of that Microsoft page describes updating an image using MDT so things are a little different when updating the USB media, but the main thing to note is the minimum drivers required to add the keyboard functionality (for each model of surface device listed).

I needed to update the boot.wim file used perform the install. The boot.wim file was found within the sources folder on the USB drive previously created.

As this file is just used during the installation we don’t need all of the drivers, just enough to start the installation and get the keyboard/trackpad working, so I copied just the required drivers folders to their own dedicated folder.

IclChipset
IclChipsetLPSS
IclChipsetNorthpeak
IclSerialIOGPIO
IclSerialIOI2C
IclSerialIOSPI
IclSerialIOUART
itouch
ManagementEngine
SurfaceDockIntegration
SurfaceHidFriendlyNames
SurfaceHidMini
SurfaceHotPlug
SurfaceSerialHub
SurfaceService
SurfaceTconDriver
surfacetouchfw
surfacetouchfw_0

The boot.wim file has two parts to it, Windows Install and Windows PE. To be on the safe side I decided to update both using the following powershell. This needs to be updated to point at the correct locations but hopefully is self-explanatory.

$MountPath = "C:\temp\Mount\"
$bootWim = "E:\sources\boot.wim"
$bootdrivers = "C:\surface_laptop\boot_drivers"
Mount-WindowsImage -Path $MountPath -ImagePath $bootWim -Index 1
Add-WindowsDriver -Path $MountPath -Driver $bootdrivers -Recurse
Dismount-WindowsImage -Path $MountPath –Save
Mount-WindowsImage -Path $MountPath -ImagePath $bootWim -Index 2
Add-WindowsDriver -Path $MountPath -Driver $bootdrivers -Recurse
Dismount-WindowsImage -Path $MountPath –Save

Now we have the drivers we can boot from the USB drive and have keyboard/mouse functionality, great! but we should also take the time to inject all the drivers into the Windows image.

Depending on the installation media the file we need could be install.wim, but it is most likely to be the more modern install.esd. In my case it was install.esd and again it is found in the sources folder on the USB drive.

As I had install.esd there are a few more steps that need to be done. Firstly, we need to find out the index number of our Windows Installation. This is done by running

DISM /Get-WimInfo /WimFile:"install.esd"

In this example the index is 1 but there could be multiple versions of windows available so pick whichever one matches your requirement.

Once we have our index number we can extract the installation and create the install.wim file we actually need.

dism /export-image /SourceImageFile:"c:\temp\install.esd" /SourceIndex:1 /DestinationImageFile:C:\temp\install.wim /Compress:max /CheckIntegrity

Now we can use PowerShell to mount the image and inject the drivers like we did for the boot.wim.

$MountPath = "C:\temp\Mount\"
$InstallWim = "c:\temp\install.wim"
$Surfacedrivers = "C:\surface_laptop\drivers"
Mount-WindowsImage -Path $MountPath -ImagePath $installWim -Index 1
Add-WindowsDriver -Path $MountPath -Driver $bootdrivers -Recurse
Dismount-WindowsImage -Path $MountPath –Save

This will take a little while and not show output until the end. After which we need to convert the install.wim file back to an esd file.

DISM /Export-Image /SourceImageFile:c:\temp\install.wim /SourceIndex:1 /DestinationImageFile:C:\temp\install.esd /Compress:recovery

Again, the conversion process can take some time.

Now all that’s left is to replace the install.esd on the USB drive with our modified version and boot the Surface device from it (using volume down & Power button) and we have a device with drivers for all hardware.

About the author