DISM - Add or Remove Drivers on an Offline Image

    DISM - Add or Remove Drivers on an Offline Image

    How to add or remove hardware device drives on an Offline Image with DISM

    Published by Kari
    12 Oct 2017 Last Updated: 2 Days Ago at 09:11

    Published by


    Kari's Avatar
    Finnish but not finished


    Location: A Finnish expat in Germany
    Posts: 12,661

    Show Printable Version 


    information   Information
    Servicing an offline image, mounting an image, committing changes, it all sounds a bit complicated to an average Windows user. However, it's just geek speak meaning modifying default Windows install image, the install.wim file. It is a straight forward procedure. When changes have been committed (written, saved) to image, the modified install.wim can be used to deploy Windows or to replace original install.wim on existing install media.

    Servicing an offline image is done with DISM (Deployment Image Servicing and Management), a native Windows tool. DISM command options allow all kind of changes, changing the way Windows will be installed. Drivers can be added or removed, language packs applied to create a multilingual Windows install media, Windows Updates applied to get a new Windows installation to be up to date straight after installation, and so on.

    A default Windows install media is hardware independent, meaning that it can be used to install Windows on any hardware capable of running Windows. Windows will be installed with default drivers, then after the installation Windows Update searches for correct drivers installing them or the user installs drivers manually using ones provided by manufacturer.

    If the install media will be used on specific hardware, you can shorten the time required to install Windows, as well as time required for post install update by adding hardware specific drivers to install media.

    This tutorial will show how to use DISM to add or remove drivers on an offline image of Windows.





    DISM - Add or Remove Drivers on an Offline Image Contents DISM - Add or Remove Drivers on an Offline Image
     Use links below to go to any step, back button of your browser to return to this list.


    Step One: Get drivers: Download
    Step Two: Get drivers: Export
    Step Three: Mount offline image
    Step Four: Add drivers to image
    Step Five: Unmount offline image
    Step Six: Create updated ISO

    Note   Note
    Steps One & Two will show both available methods to get drivers to be added to image. Usually you would need to use one of the methods to get correct drivers, download drivers from manufacturer's site or export drivers from an existing Windows 10 installation on exactly the same hardware. However, there's nothing to prevent using both methods; you could for instance export drivers from an existing Windows installation on similar but not exactly the same hardware setup, then remove drivers that are different on hardware where your install media will be used and download those drivers from manufacturer's site.

    Exporting drivers from an existing installation on same hardware is my preferred method. Exporting the full set of drivers and adding them to offline image is very practical especially for private users who want to make an install media for their own hardware. A reinstall using such media is as easy as it can be, providing a complete Out-of-Box Windows installation without any need to start installing hardware drivers after the installation.




    DISM - Add or Remove Drivers on an Offline Image Step One DISM - Add or Remove Drivers on an Offline Image
     Get drivers: Download
    1.1) Download required drivers from manufacturer's site

    1.2) Most often the drivers come as a self-extracting executable (.exe) or archived (.zip) file. You must extract drivers first, an archive file can't be used. To be able to add an individual driver, you will need its .inf file





    DISM - Add or Remove Drivers on an Offline Image Step Two DISM - Add or Remove Drivers on an Offline Image
     Get drivers: Export
    2.1) Create a new folder for exported drivers, in this example I'll make it as D:\Drivers

    2.2) To export all hardware drivers from an existing Windows 10 installation, use following command in elevated PowerShell (tutorial), replacing path D:\Drivers with your actual path:

    dism /Online /Export-Driver /Destination:D:\Drivers

    Drivers will be exported to your chosen folder:
    Click image for larger version. 

Name:	image.png 
Views:	21 
Size:	524.4 KB 
ID:	157613

    Note   Note
    Exporting drivers with DISM does not give much information about what was exported. Folder names for individual drivers as shown in sample screenshot above in 2.2 are also not very informative.

    If you want to know what is exported, you can use PowerShell cmdlets instead. First, I will export drivers saving the exported driver information to a variable $Drivers (use any variable name you prefer) with following command:

    $Drivers = Export-WindowsDriver -Online -Destination D:\Drivers

    Now I can ask PowerShell to show me the contents of variable $Drivers, sorting it as I prefer:

    $Drivers | Select-Object ClassName, ProviderName, Date, Version | Sort-Object ClassName
    Click image for larger version. 

Name:	image.png 
Views:	18 
Size:	832.5 KB 
ID:	157614

    Exported drivers are the same than when using DISM command instead, it's just that using PowerShell cmdlets I can get some valuable information about what was exported.




    DISM - Add or Remove Drivers on an Offline Image Step Three DISM - Add or Remove Drivers on an Offline Image
     Mount Offline Image
    3.1) Create a new folder to temporarily store the contents of Windows 10 ISO image, name it as you want to. In this example I create the folder on drive D: naming it ISO_Files.

    3.2) Mount a Windows 10 ISO image as virtual DVD by double clicking it, alternatively right clicking it and selecting Mount. Open mounted ISO in Explorer, select all files and folders with CTRL + A and copy them with CTRL + C, paste the ISO content to ISO_Files folder with CTRL + V:






    Note   Note
    If you have Windows 10 install media on a USB flash drive, you can skip steps 3.1 & 3.2 and use it instead.

    3.3) Create a folder to mount offline image. In this example I use folder C:\Mount.

    3.4) Open elevated PowerShell (tutorial). Enter following command to check what editions are included in image:

    Dism /Get-WimInfo /WimFile:D:\ISO_Files\Sources\install.wim

    Note the index number of your selected edition. In this example I have copied all content of Windows 10 Fall Creators Update version 1709 to ISO_Files folder. I want to use PRO edition to add drivers to it, noting its index number 8:



    3.5) Mount the image of your preferred Windows 10 edition using it's index number, index 8 in this example:

    Dism /Mount-Wim /WimFile:D:\ISO_Files\Sources\install.wim /Index:8 /MountDir:C:\Mount

    This will take some time. Please notice, the drive where the Mount folder is located needs some free space. I do not recommend mounting an image to a folder on a drive with less than 15 GB free space. For instance, mounting the multi edition build 16299.15 image requires almost 12 GB, in addition to space required to work with the image:
    Name:  image.png
Views: 152
Size:  105.9 KB





    DISM - Add or Remove Drivers on an Offline Image Step Four DISM - Add or Remove Drivers on an Offline Image
     Add drivers to image

    Note   Note
    You can always check which drivers are already present in offline image with following command:

    Dism /Image:C:\Mount /Get-Drivers
    4,1) If you downloaded individual drivers, you can add them now to offline mounted image with following command:

    dism /Image:C:\Mount /Add-Driver /Driver:X:\Drivers\DriverName.inf

    Replace mount folder path C:\Mount in above sample command with actual path to your mount folder, and driver path and name X:\Drivers\DriverName.inf with actual path to downloaded driver

    4.2) If the driver is unsigned, use the following command:

    dism /Image:C:\Mount /Add-Driver /Driver:X:\Drivers\DriverName.inf /ForceUnsigned

    4.3) If you want to remove a driver from offline image, use the following command:

    dism /Image:C:\Mount /Remove-Driver /Driver:X:\Drivers\DriverName.inf

    4.4) With /Add-Driver and /Remove-Driver you can add or remove multiple drivers:

    dism /Image:C:\Mount /Add-Driver /Driver:X:\Drivers\DriverName.inf /Driver:X:\Drivers\Driver2Name.inf

    4.5) If you have drivers on one folder and its subfolders, like for instance when exported from an existing installation, you can add all drivers with one simple command, replacing mount folder and drivers folder paths with your actual paths:

    dism /Image:C:\Mount /Add-Driver /Driver:D:\Drivers /Recurse

    /Recurse switch will tell PowerShell to go through the main folder and its subfolders, adding all drivers it finds:
    Click image for larger version. 

Name:	image.png 
Views:	18 
Size:	1.63 MB 
ID:	157617
    (Click to enlarge.)




    DISM - Add or Remove Drivers on an Offline Image Step Five DISM - Add or Remove Drivers on an Offline Image
     Unmount offline image
    5.1) All done, you can save changes and unmount offline image with following command:

    dism /Unmount-Image /MountDir:C:\Mount /Commit
    Name:  image.png
Views: 156
Size:  120.1 KB

    The /Commit switch is the important one, it commits (saves) all changes to the image.





    DISM - Add or Remove Drivers on an Offline Image Step Six DISM - Add or Remove Drivers on an Offline Image
     Create updated ISO
    6.1) If you were using install.wim from a USB flash drive, you are ready. It now contains an updated Windows install image

    6.2) If you were using ISO_Files folder on HDD, it now contains all files needed to create an updated ISO image. See Part Five in following tutorial for instructions in creating the ISO: Create Windows 10 ISO image from Existing Installation Installation Upgrade Tutorials


    That's it! If you have any issues with this, do not hesitate to post in this thread.

    Kari


  1.    1 Week Ago #1
    Join Date : Jul 2015
    Posts : 47
    Windows 10 64bit

    Question, does PersistAllDeviceInstalls need to be in Sysprep?

    Also should there be a second reminder that adding drivers to a DISM image is hardware dependent
      My ComputerSystem Spec
  2.    1 Week Ago #2
    Join Date : Oct 2013
    A Finnish expat in Germany
    Posts : 12,661
    Windows 10 Pro
    Thread Starter

    Quote Originally Posted by Jerry06 View Post
    Question, does PersistAllDeviceInstalls need to be in Sysprep?
    Yes, in answer file.


    Quote Originally Posted by Jerry06 View Post
    Also should there be a second reminder that adding drivers to a DISM image is hardware dependent
    That is so obvious, who on earth would think that adding for instance NVidia GPU drivers to media used to install on system with AMD GPU would work?

    Anyway, that is mentioned at the beginning of the tutorial:
    information   Information
    A default Windows install media is hardware independent, meaning that it can be used to install Windows on any hardware capable of running Windows. Windows will be installed with default drivers, then after the installation Windows Update searches for correct drivers installing them or the user installs drivers manually using ones provided by manufacturer.

    If the install media will be used on specific hardware, you can shorten the time required to install Windows, as well as time required for post install update by adding hardware specific drivers to install media.

    Kari
      My ComputerSystem Spec
  3.    1 Week Ago #3
    Join Date : Jul 2015
    Posts : 47
    Windows 10 64bit

    Thanks. Sorry about the second part with the reminder suggestion.
      My ComputerSystem Spec
  4.    1 Week Ago #4
    Join Date : Jan 2014
    Posts : 1,385
    Windows 10 Pro (32-bit) Insider 16291

    Ah I thought you might be doing the DISM/drivers one.

    It is good info and I use parts of this frequently when I'm reinstalling on my old hardware and need to manually add drivers.

    I would suggest DISM /Get-Drivers as an alternate to the Powershell step in 2.2 - the table format is quite useful I find.

    One method of applying the drivers I tried which seems to work (not sure how valid it is) when clean-installing a machine as a one-off:
    1. Export drivers as per Step 2
    2. Use DISM /Get-Drivers to show which driver is which, and copy only the ones I know are problematic to a subfolder, and add this subfolder to a bootable Windows 10 Setup USB
    3. Boot Windows 10 Setup from the USB
    4. Open a command prompt with Shift F10, type command 'wpeutil shutdown' but don't press enter. Instead, Alt-Tab back to Setup
    5. Follow the normal clean install process, delete partitions and let it install the relevant edition
    6. When it says Restarting in a few seconds, quickly Alt-Tab to the command prompt and press enter, to stop it restarting but shut down instead
    7. Boot again from the USB, go straight into Shift-F10, and use DISM /add-driver to add relevant drivers to the offline Windows drive as per Step 4
    8. wpeutil shutdown again, and let it restart this time, so that Windows boots and finishes configuring itself with the new drivers available to it.

    I found it easier than Mounting the image and also means I don't change the .WIM so I can use that on other hardware without fear of non-standard (and probably quite old) drivers getting in the way .

    Although in some cases I could install and change it once Windows is up and running , one of 1709's default drivers causes a BSOD during installation itself, if I don't add the alternative manually using the above technique before it gets to that point.

    But it's not a technique I've seen anywhere else so I'm probably bending the rules somewhere.
      My ComputerSystem Spec

 


Similar Threads
Tutorial Category
General Tips DISM - Edit Registry on an Offline Image
Servicing an offline image, mounting an image, committing changes, it all sounds a bit complicated to an average Windows user. However, it's just geek speak meaning modifying default Windows install image, the install.wim file. It is a straight...
Tutorials
Performance & Maintenance Use DISM to Repair Windows 10 Image
How to Repair Windows 10 Image using DISM If a Windows image becomes unserviceable, you can use the Deployment Imaging and Servicing Management (DISM) tool to update the files and correct the problem. For example, you would use DISM to fix...
Tutorials
SFC Scannow or DISM/RestoreHealth using Image
Windows 10 user. Having some trouble with my system after coming back from a weekend. Nothing major...just having trouble playing some games that require plugins etc Regardless if it's related, I just wanted to run an SFC/Scannow or...
Performance & Maintenance
Dism /Apply-Image and remove the entire content of the directory
Hi I installed Windows ADK 10 v1511 on Windows 10 v1511 Enterprise 64 bit. I typed the following commands: Dism /Apply-Image /ImageFile:"<wim_File_Path>\install.wim" /Index:1 /ApplyDir:"<Apply_Directory_Path>" /Verify /CheckIntegrity...
General Support
dism offline repair fails with 'The cleanup-image option is unknown."
Hello I have a laptop that I took the HDD out of and connected it to another Windows 10 machine. I ran the command Dism /Image:e:\ /Cleanup-Image /RestoreHealth but get the error Deployment Image Servicing and Management tool Version:...
Windows Updates and Activation
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 05:53.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums