In this article, we will show you how to add the necessary device drivers directly into the Windows installation image. The integration of the device drivers into your offline Windows image is widely used when you need to deploy a large number of workstations and servers on the same hardware. Instead of manually installing specific drivers (including AHCI/ RAID/ NVMe) on each device, you can significantly simplify and accelerate OS deployment process by integrating the drivers directly into the Driver Store of the Windows installation image in the ISO/WIM or the VHD/VHDX file. When installing such an image, the Plug and Play service (PnP) will automatically install the necessary drivers for the detected hardware.
This manual is about the integration of device drivers into a Windows image and can be used both on desktop editions of Windows 10, Windows 8.1 and on Windows Server 2016, 2012 R2.
In modern Windows editions you can add drivers to the installation ISO image in two ways:
- using the DISM utility;
- using the PowerShell CLI.
In fact, both techniques perform the same operation: add additional drivers into the offline Windows image. How to use it is a matter of personal administrator preference. Let us consider in more detail both ways on the example of integrating drivers into the Windows 10 installation image.
How to Inject Driver into a Windows 10 Install Image using PowerShell?
First of all you need to download and place all the necessary device drivers in one directory (for each driver you need to create a separate folder). Please note that many vendors (including Dell, HP) supply their drivers in the form of self-extracting exe or zip archive files. Such archives must be unpacked to local drive so that the directory with drivers contains inf, cat and sys files.
Before you start, create the following directory structure on your local drive:
- The Drivers folder – it contains unpacked driver files for your Windows 10 edition (which are supposed to be integrated into the install media); You can download and unpack the necessary driver files manually or export all third-party drivers from a reference Windows 10 computer, on which all the necessary drivers are already installed (using the Export-WindowsDriver cmdlet).
- The ISO folder – this directory contains the unpacked iso image of Windows 10. You only need the Install.wim file from the Sources directory; If your Windows 10 ISO image contains only the file ..\sources\install.esd, you can convert the ESD file to WIM format using the DISM tool:
dism /export-image /SourceImageFile:"C:\WinWork\ISO\install.esd" /SourceIndex:4 /DestinationImageFile:C:\WinWork\ISO\install.wim /Compress:max /CheckIntegrity
- The Mount folder – an empty directory into which the Windows install WIM image will be mounted later.
List all Windows editions contained in the Install.wim file using the Get-WindowsImage PowerShell cmdlet. This is necessary in order to specify the Widows edition into which it is planned to integrate the additional drivers.
Get-WindowsImage -ImagePath C:\WinWork\ISO\install.wim
In our example, the WIM file contains only one Windows 10 Pro edition with the index 1 (ImageIndex: 1).
Next you need to mount the image of the selected Windows edition in the directory Mount. The Windows image index, which you need to mount, must be specified as an argument of the Index parameter:
Mount-WindowsImage -Path C:\WinWork\Mount\ -ImagePath C:\WinWork\ISO\install.wim -Index 1
After the image is mounted, you can add drivers to it from the Drivers directory using the command:
Add-WindowsDriver -Path C:\WinWork\Mount\ -Driver C:\WinWork\Drivers -Recurse
The Add-WindowsDriver cmdlet will recursively search (the -Recurse parameter) the specified folder for all *.inf files with driver description. According to the description in the inf file, the cmdlet will add the dependent INF, DLL, CAT, PNF, etc. files to the Driver Store of your Windows image.
So, the drivers are copied, and the current image can be unmounted with saving changes:
Dismount-WindowsImage -Path C:\WinWork\Mount\ –Save
In the above example, we added drivers to the Install.wim image file. This is the Windows image that will be deployed to a computer local disk. If you need to add drivers to a Windows boot image (from which the computer boots when you install Windows), you need to add drivers to the Boot.wim file. This is usually necessary when installing Windows, the computer doesn’t detect local hard drives or doesn’t connect to LAN. Usually, only drivers of disk controllers and network adapters need to be integrated into the boot.wim image.
You can convert your install.wim file containing the Windows installation image with integrated drivers into the install.esd format using the DISM compress option:
DISM /Export-Image /SourceImageFile:C:\WinWork\ISO\install.wim /SourceIndex:1 /DestinationImageFile:C:\WinWork\ISO\install.esd /Compress:recovery
oscdimg -n -m -bc:\ISO\boot\etfsboot.com C:\ISO C:\new_win10pro_image.iso
Adding Drivers to an Offline Windows Server 2012 R2 Image Using DISM
Now we will show an example of integrating drivers into the install image of Windows Server 2012 R2. If you are building an image on Windows 8.1, you will need to download and install Windows 8 ADK (http://www.microsoft.com/en-us/download/details.aspx?id=30652) to continue working with the latest version of DISM. You need to install the Deployment Tools component.
Use the same directory structure: Drivers (drivers and *.inf files are stored), ISO (unpacked image of Windows Server 2012 R2), Mount (image mount directory). It is assumed that in the install.wim file we are interested in the Windows Server 2012 R2 Datacenter edition with index 3.
Mount the install.wim installation image:
dism /Mount-Wim /WimFile:c:\iso\sources\install.wim /Index:3 /MountDir:c:\mount
Run a recursive search and integration of the new drivers into the driver store of the Windows Server 2012 R2 image:
dism /image:c:\mount /Add-Driver "/driver:c:\drivers\" /recurse
Save the changes to the WIM image:
dism /unmount-wim /mountdir:d:\mount /commit
If you need to add drivers to all Windows Server editions contained in the wim file, these operations must be performed for all indexes of OS versions that the command returned:
dism /get-wiminfo /wimfile:d:\install.wim
In addition to driver integration, it is usually necessary to inject security updates to the Windows image to be installed (How to add updates into the Windows installation image). This will increase the security of your OS immediately after the installation. It remains to write the resulting installation image to the DVD disk or USB flash drive or convert it to the ISO image.