# Adding Drivers to a Windows 7 Image Offline

In my previous post I provided instructions on how to capture a Windows 7 image whereas here I will cover how to add drivers to an offline .wim image which you may have captured previously.

There are two ways to add drivers to an offline Windows 7 image, both require the use of DISM to mount the image and then add the drivers.

The first is using an answer file with DriverPath entries pointing to device drivers and applying the answer file to the .wim image offline. The second is using DISM command line options to directly point to .inf files without the use of an answer file.

But is there a third method? I cover this at the end of this post under Method 3.

# Method 1: Using Answer Files to Point to Device Drivers

I am familiar with using unattended answer files to install drivers as I covered this in Experiments with Sysprep, but that was as part of the Sysprep process.

Adding drivers an offline image is slightly different however – you use DISM to apply the answer file to the .wim image instead of using Sysprep.

I have previously provided step by step instructions on how to build unattended answer files using the Windows SIM tool so I will not cover this again. Instead the instructions here will be more in note form.

Using Windows SIM add the amd64_Microsoft-Windows-PnpCustomizationsNonWinPE_neutral component to the offlineServicing configuration pass.

In the Answer File pane expand the Microsoft-Windows-PnpCustomizationsNonWinPE component. Right-click DevicePaths, and select Insert New PathAndCredentials

In the Properties pane add the path to the device drivers in the Path field and type 1 in the Key field. If the path is in a network share then expand PathAndCredential in the Answer File pane, select Credentials and type your credentials in the Properties pane.

You can add multiple driver path entries but for each entry make sure to increment the Key value each time. First driver path entry has a Key vale of 1, the second driver path entry has a Key vale of 2 and so on.

Mount the Windows image

Open the Deployment Tools Command Prompt and type something like this to mount the image offline

Dism /Mount-Wim /WimFile:C:\My-Wims\ref-win7-image.wim /Index:1 /MountDir:C:\ wim-mount-dir

Apply the answer file to the mounted image using DISM

DISM /Image:C:\wim-mount-dir /Apply-Unattend:C:\unattend-answer-files\oflinedrivers.xml

Unmount the Windows Image

Dism /Unmount-Wim /MountDir:C:\wim-mount-dir /commit
Don’t forget the /commit switch otherwise changes to the image will not apply.

# Method 2: Using DISM to add individual INF files

This is a much easier method as it doesn’t involve the hassle of building answer files. Instead you issue DISM commands at the Deployment Tools Command Prompt to add inf files to an image.

Mount the Windows Image

At the Deployment Tools Command Prompt and type something like this to mount the image

Dism /Mount-Wim /WimFile:C:\My-Wims\ref-win7-image.wim /Index:1 /MountDir:C:\wim-mount-dir

Add an .INF Driver to an Image

Dism /Image:C:\wim-mount-dir /Add-Driver /Driver:C:\my-drivers\audio-driver.inf

Multiple drivers can be added by simply pointing to a folder which will install all .inf drivers found in that directory. To add drivers from subdirectories too use the /Resurse switch

Dism /Image:C:\wim-mount-dir /Add-Driver /Driver:C:\my-drivers /recurse

64-bit computers require drivers to have a digital signature (i.e. signed drivers). To get past this requirement use the /ForceUnsigned switch to install unsigned drivers

Dism /Image:C:\wim-mount-dir /Add-Driver /Driver:C:\my-drivers /ForceUnsigned

Unmount the Windows Image

Dism /Unmount-Wim /MountDir:C:\wim-mount-dir /commit
Again, without the /commit switch none of your changes will be saved to the image.

# Method 3: Copy device drivers to C:\Windows\INF\

During the Windows 7 installation process Setup searches for device drivers in the C:\Windows\INF\ directory including all subdirectories for devices on the computer and installs them as part of the same process ready to be used upon first log on.

I initially based my theory on the fact that all in-box and out of box drivers are stored in this directory so manually copying drivers here should allow Setup to find and install these drivers. I’ve found this to work absolutely fine in all my tests, including offline. (I’ve already mentioned how this works in Experiments with Sysprep and Preparing and Sysprep’ing the Reference Computer).

Here’s how this works in an offline scenario

Mount the Windows Image

At the Deployment Tools Command Prompt and type something like this to mount the image

Dism /Mount-Wim /WimFile:C:\My-Wims\ref-win7-image.wim /Index:1 /MountDir:C:\wim-mount-dir

Copy device drivers to C:\wim-mount-dir\Windows\INF\

Device drivers must be .inf files and not .exe applications. You might want to organise it in subfolders, for example

C:\Windows\INF\MyDrivers\audio64

C:\Windows\INF\MyDrivers\ethernet64

C:\Windows\INF\MyDrivers\chipset64

etc

Unmount the Windows Image

Dism /Unmount-Wim /MountDir:C:\wim-mount-dir /commit

When the .wim image is applied to a computer and turned on for the first time the device drivers will install as part of the Windows installation process, no problem.

Coming up next is Applying a Windows 7 image using ImageX.