Drivers Injection For Windows Installation
💉

Drivers Injection For Windows Installation

Tags
windows
surface pro
drivers
Published
August 2, 2023
Quick View
If you are a Microsoft Surface user and ever find yourself needing to reinstall Windows, you might encounter an issue where the keyboard and trackpad that came with your Surface device won't work during the fresh Windows installation. This can be frustrating, especially if you're facing problems like faulty updates and frequent BSOD (Blue Screen of Death) errors that spoil the overall experience.
To follow this tutorial, you'll require a USB stick 2.0 with an adapter, or ideally, a USB Type-C stick for faster read/write speeds, along with a Windows computer.
To begin, you'll need to create a Windows 10 or 11 Installation Media from the official Microsoft website. The installation process is quite straightforward, and since it involves simple steps, we won't delve into it further as there are numerous online videos and guides available to assist you.

Step 1: Downloading the Surface Pro Drivers

First thing you need is to download the surface pro drivers from Surface Pro Drivers

Step 2: Creating Temporary Folders

To create temporary folders named tmp and tmp\Mount on your Windows system, follow these steps:
  1. Open PowerShell: You can open PowerShell by searching for "PowerShell" in the Start menu or by pressing `Win + X` and selecting "Windows PowerShell."
  1. Copy the PowerShell script below o create temporary folders named tmp and tmp\Mount on your Windows system, open PowerShell with administrative privileges and run the following commands:
    1. # Create C:\tmp if it doesn't exist New-Item -Path "C:\tmp" -ItemType Directory -Force # Create C:\tmp\Mount if it doesn't exist New-Item -Path "C:\tmp\Mount" -ItemType Directory -Force
After running the commands, you will have successfully created the tmp and tmp\Mount temporary folders on your system.

Step 3: Extract drivers Content

  1. Copy the downloaded driver: Copy the downloaded Surface Pro driver (usually in .msi format) to the C:\tmp folder on your computer.
  1. Navigate to the C:\tmp folder: Use the cd (Change Directory) command to navigate to the C:\tmp folder where you copied the driver. For example:
    1. cd C:\tmp
  1. Run the following command to extract the driver content to the same folder:
    1. msiexec.exe /a <MSI File Name>.msi targetdir=C:\tmp /qn
      Replace with the actual name of the MSI file you copied.

Step 5: Rename the Boot Drivers Folder

Navigate to the C:\tmp\surface_laptop folder: Use the cd (Change Directory) command to navigate to the C:\tmp\surface_laptop folder where you extracted the driver content. For example:
cd C:\tmp\surface_laptop # List the contents of the directory to find the folder name Get-ChildItem # Rename the folder to "drivers" (replace "OldFolderName" with the actual folder name you want to rename) Rename-Item -Path .\OldFolderName -NewName "drivers"
After running these commands, the folder within C:\tmp\surface_laptop will be renamed to drivers.

Step 6: Check and memorize the USB Stick's Drive Letter

Before proceeding further, it's essential to check and memorize the drive letter assigned to your USB stick. This step is crucial as it will help us identify the correct drive to copy the necessary files in the following steps. You can do this by opening a new explorer Win + E, locate your USB stick in the left sidebar of File Explorer and note the letter somewhere.

Step 7: Mount the boot.wim File

In this step, we will mount the boot.wim file located on the USB drive (e.g., E:\sources\boot.wim). This will allow us to add additional drivers to the Windows image. To mount the boot.wim file and add the drivers, follow these steps:
  1. Open PowerShell: If you haven't already, open PowerShell by searching for "PowerShell" in the Start menu or by pressing Win + X and selecting "Windows PowerShell."
  1. Set the paths: In PowerShell, copy and paste the following lines to set the required paths:
    1. # Set the mount path for the Windows image $MountPath = "C:\temp\Mount\" # Set the path to the boot.wim file on the USB drive (replace "E:\" with the drive letter of your USB stick) $bootWim = "E:\sources\boot.wim" # Set the path to the drivers folder $drivers = "C:\tmp\surface_laptop\drivers"
  1. Mount the boot.wim file: Run the following command to mount the boot.wim file to the specified mount path:
    1. Mount-WindowsImage -Path $MountPath -ImagePath $bootWim -Index 1
  1. Add the drivers: Now, add the boot drivers from the drivers folder to the mounted Windows image using the following command:
    1. Add-WindowsDriver -Path $MountPath -Driver $drivers -Recurse
  1. Dismount the image: Finally, run the following command to dismount the Windows image and save the changes:
    1. Dismount-WindowsImage -Path $MountPath -Save
Sure! To mount and add drivers to index 2 of the boot.wim file, follow the modified steps below:

Step 8: Mount the boot.wim File (Index 2)

  1. Mount the boot.wim file (Index 2): Run the following command to mount index 2 of the boot.wim file to the specified mount path:
    1. Mount-WindowsImage -Path $MountPath -ImagePath $bootWim -Index 2
  1. Add the drivers: Now, add the boot drivers from the drivers folder to the mounted Windows image (Index 2) using the following command:
    1. Add-WindowsDriver -Path $MountPath -Driver $drivers -Recurse
  1. Dismount the image: Finally, run the following command to dismount the Windows image (Index 2) and save the changes:
    1. Dismount-WindowsImage -Path $MountPath -Save

Notes on Injecting Drivers

Please note that the boot.wim file modification, as described in the previous steps, is specific to the Windows installation environment and is used during the initial boot and setup process. The changes made to boot.wim are not directly reflected in the installed Windows operating system.
To ensure that the drivers are available and functional within the installed Windows, you will also need to inject the drivers into the actual Windows installation media or apply them to the installed Windows.
For injecting drivers into an offline Windows image, you can use the Deployment Image Servicing and Management (DISM) tool. DISM allows you to modify an offline Windows image by adding or removing components, packages, and drivers.

Step 9: Manually Copy install.esd from Your USB Stick to C:\tmp

In this step, we will manually copy the install.esd file from your USB stick to the C:\tmp folder on your computer. The install.esd file is an essential component as it contains the Windows installation image in a compressed and read-only format.
Why is the install.esd file used?
The install.esd file is used to store the Windows installation image, which includes all the necessary files required to install or upgrade Windows on your computer. It is a highly compressed and read-only file format designed to reduce the overall size of the Windows installation media.
Follow the steps below to copy the install.esd file:
  1. Locate the install.esd file: In File Explorer, navigate to your USB stick (e.g., E:) and then to the folder sources where the install.esd file is located.
  1. Copy the install.esd file: Copy the file install.esd from your usb stick to the C:\tmp folder.
  1. Rename the install.esd file: Rename the install.esd file to bkp_install.esd to avoid losing the file when mounting it.

Notes On Task Duration

Starting from Step 10, the process may take a few minutes to up to 1 hour to accomplish the task, depending on various factors such as the size of the Windows image, the processing power of your computer, and the speed of your storage devices.

Step 10: Convert the .esd to .wim

In this step, we will convert the .esd (Electronic Software Distribution) file to the .wim (Windows Imaging Format) file. The conversion is necessary because .wim files offer more flexibility and are commonly used for customizing and deploying Windows images.
Run the conversion command: In PowerShell, copy and paste the following command to convert the .esd file to the .wim format:
dism /export-image /SourceImageFile:"C:\tmp\bkp_install.esd" /SourceIndex:1 /DestinationImageFile:C:\tmp\install.wim /Compress:max /CheckIntegrity
After executing the command, the .esd file will be converted to .wim, and the resulting .wim file (C:\tmp\install.wim) can now be further customized, updated, or deployed using various Windows deployment tools and processes.

Step 11: Inject Drivers into the Windows Installation

In this step, we will inject the necessary drivers into the Windows installation image (.wim format) that we created in Step 10. By injecting drivers, we ensure that the Windows installation includes the required drivers for proper hardware support on target devices.
  1. Set the paths: In PowerShell, copy and paste the following lines to set the required paths:
    1. # Set the mount path for the Windows image $MountPath = "C:\temp\Mount\" # Set the path to the Windows installation image in .wim format (replace "c:\tmp\install.wim" with the actual path) $installWim = "c:\tmp\install.wim" # Set the path to the drivers folder (replace "C:\tmp\surface_laptop\drivers" with the actual path) $drivers = "C:\tmp\surface_laptop\drivers"
  1. Mount the Windows image: Run the following command to mount the Windows installation image (.wim) to the specified mount path:
    1. Mount-WindowsImage -Path $MountPath -ImagePath $installWim -Index 1
  1. Add the drivers: Now, inject the drivers from the drivers folder into the mounted Windows image using the following command:
    1. Add-WindowsDriver -Path $MountPath -Driver $drivers -Recurse
  1. Dismount the image: Finally, run the following command to dismount the Windows image and save the changes:
    1. Dismount-WindowsImage -Path $MountPath -Save

Step 12: Convert .wim back to .esd

In this step, we will convert the modified .wim file back to the .esd format. The .esd format is used for efficient storage of the Windows installation image, allowing us to create a compact and space-saving Windows installation media.
  1. Set the paths: In PowerShell, copy and paste the following lines to set the required paths:
    1. # Set the path to the modified Windows installation image in .wim format (replace "C:\tmp\install.wim" with the actual path) $wimPath = "C:\tmp\install.wim" # Set the path for the resulting Windows installation image in .esd format (replace "C:\tmp\install.esd" with the desired path) $esdPath = "C:\tmp\install.esd"
  1. Run the conversion command: Now, execute the following command to convert the .wim file back to .esd:
    1. DISM /Export-Image /SourceImageFile:$wimPath /SourceIndex:1 /DestinationImageFile:$esdPath /Compress:recovery

Step 13: Replace the install.esd on Your USB Stick

In this final step, we will remove the existing install.esd file from your USB stick and replace it with the newly created install.esd file that we modified and converted.
Follow these steps to replace the install.esd on your USB stick:
  1. Copy the newly created install.esd: Navigate to the location where you saved the newly created install.esd file (e.g., C:\tmp\install.esd).
  1. Replace the install.esd: Delete the existing install.esd file on your USB stick which is on this path E:\sources\install.esd.
  1. Copy the newly created install.esd: copy the newly created install.esd to your USB stick.
  1. Safely eject your USB Drive: To avoid any data loss or damage, safely eject your usb stick before removing it from your computer.

Finally

The blog concludes with replacing the original install.esd file on your USB stick with the customized version, making it ready for your Surface Pro installation. Say goodbye to the hassle of external peripherals – now you can effortlessly install Windows with complete trackpad and keyboard support.