Install windows driver from command line

DISM Driver Servicing (.inf) Command-Line Options

Use DISM with INF-style drivers to add, remove, or list drivers to an online or offline Windows image (.wim). Microsoft Windows Installer or other driver package types (such as .exe files) are not supported.

You can specify a directory where the driver INF files are located, or you can point to a driver by specifying the name of the INF file.

The base syntax for servicing a Windows image using DISM is:

The following driver servicing options are available for an offline image.

DISM.exe /image: [/Get-Drivers | /Get-DriverInfo | /Add-Driver | /Remove-Driver | /Export-Driver]

The following driver servicing options are available for a running operating system.

DISM.exe /Online [/Get-Drivers | /Get-DriverInfo | /Export-Driver]

The following table provides a description of how each driver servicing option can be used. These options are not case sensitive.

Option: /Get-Help /?

When used immediately after a driver servicing command-line option, information about the option and the arguments is displayed. Additional topics might become available when an image is specified.

Dism /image:C:\test\offline /Add-Driver /?

Dism /online /Get-Drivers /?

Option: /Get-Drivers

/All

Displays basic information about driver packages in the online or offline image.

By default, only third-party drivers will be listed. Use the /all argument to display information about default drivers and third-party drivers. Use the /Format:Table or /Format:List argument to display the output as a table or a list.

If you point to an image, you can determine what drivers are in the image, in addition to the state of the drivers (installed or staged).

Dism /image:C:\test\offline /Get-Drivers

Dism /online /Get-Drivers

Option: /Get-DriverInfo

/Driver:

/Driver:

Displays detailed information about a specific driver package.

You can point to an INF file installed in the image, or one that is not yet installed. You can specify the name of the uninstalled driver or the third-party driver in the device driver store. Installed third-party drivers in the driver store will be named Oem0.inf, Oem1.inf, and so on. This is referred to as the published name.

You can specify multiple drivers on the command line by using the /driver option multiple times.

First, use the /Get-Drivers option so that you can identify a driver INF file. Then run the following command:

Dism /image:C:\test\offline /Get-DriverInfo /driver:

Dism /online /Get-DriverInfo /driver:C:\test\drivers\usb\usb.inf

Option: /Add-Driver

/Driver:

/Driver:

/Recurse

/ForceUnsigned

Adds third-party driver packages to an offline Windows image.

When you use the /Driver option to point to a folder, INF files that are not valid driver packages are ignored. These files are reported on the console when the command runs, and a warning is included in the log file. You will not receive an error message.

If you point to a path and use the /Recurse option, all subfolders are queried for drivers to add.

For testing purposes you can use /ForceUnsigned to add unsigned drivers and override the requirement that drivers installed on X64-based computers must have a digital signature. For more information about driver signing requirements, see Device Drivers and Deployment Overview.

Dism /image:C:\test\offline /Add-Driver /driver:C:\test\drivers

Dism /image:C:\test\offline /Add-Driver /driver:C:\test\drivers /recurse

Dism /image:C:\test\offline /Add-Driver /driver:C:\test\drivers\mydriver.inf

Dism /image:C:\test\offline /Add-Driver /driver:C:\test\drivers\mydriver.inf /ForceUnsigned

Option: /Remove-Driver

/Driver:

Removes third-party drivers from an offline image.

When third-party drivers are added, they are named Oem0.inf, Oem1.inf, and so on. You must specify the (for example, Oem1.inf) to remove the driver. You cannot remove default drivers.

Removing a boot-critical driver package can make the offline Windows image unbootable.

You can specify multiple drivers on the command line by using the /Driver option multiple times.

Dism /image:C:\test\offline /Remove-Driver /driver:oem1.inf

Dism /image: C:\test\offline /Remove-Driver /driver:oem1.inf /driver:oem2.inf

Option: /Export-Driver

/Destination:

Exports all third-party driver packages from a Windows image to a destination path. The exported drivers can then be injected to an offline image by running the DISM Add-Driver command. This command is new for Windows 8.1 Update.

DISM /Online /Export-Driver /Destination:C:\destpath

DISM /Image:C\test\offline /Export-Driver /Destination:C:\destpath

Limitations

The driver servicing command supports only .inf files. Windows Installer or other driver package types (such as .exe files) are not supported.

Drivers are installed in the order that they are listed in the command line. In the following example, 1.inf, 2.inf, and 3.inf will be installed in the order that they are listed in the command line.

Install windows driver from command line

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I am trying to install driver using INF file from command line using rundll32.exe. Following is the command which I am using:

rundll32 setupapi, InsatllHinfSection DefaultInstall 132 .inf

But it is failing consistantly with message boc «Installation Failed». If I right-click on the same INF file and «Install», then driver is installed properly. If I use this same command on x86 platform then also it works fine.

After searching I came to know that this is the same command which I need to use to install driver using INF on Windows 64 bit version. Am I doing something wrong? Please help me out in this. Thanks in advance.

Answers

I’ve learned a lot about this particular method. In short, starting in Vista, DefaultInstall sections will need to be platform specific if the platform is specific 🙂 DefaultInstalls which fail with «Installation Failed» will succeed if the section is decorated (e.g. DefaultInstall.amd64)

However, it should be understood, you can’t actually install a driver this way. DefaultInstall is a legacy method which will only (1) copy files and (2) create a service section. Nothing else (for the most part). Driver Installation is more complicated than this and indeed, DefaultInstall also has no concept of what a signed driver is and the CAT file will never be properly moved over the the CATDB. FYI (See: http://msdn.microsoft.com/en-us/library/ff547356(VS.85).aspx ) and

Note The INF file of a driver package must not contain an INF DefaultInstall section if the driver package is to be digitally signed. For more information about signing driver packages, see Driver Signing .

It’s better to use SetupDI to install drivers instead of this method.

Daniel Whitaker WDK Support Team

  • Proposed as answer by Emberstone Microsoft employee Thursday, March 10, 2011 6:50 PM
  • Unproposed as answer by markRoddy Thursday, March 10, 2011 7:20 PM
  • Marked as answer by Doron Holan [MSFT] Tuesday, January 8, 2013 7:53 AM

All replies

Given that is a cut & paste, I would suggest you check your spelling. Should it not be InstallHinfSection, instead of InsatllHinfSection? G’ooness, even the spell checker on this browser interface doesn’t like the second form, or as you spelled it.

Gary G. Little NanoTelesis Systems, LLC

I have the same problem while installing the scanner sample from wdk on windows 7 by the commandline written below..

rundll32 syssetup,SetupInfObjectInstallAction DefaultInstall 128 «c:\My Files\WDKsamples\scanner.INF»

When I right-click ->Install this file then driver gets installed and keeps the files to their respective paths.

Please help me . Thanks in Advanvce.

I have problem while installing the scanner sample from wdk on windows 7 by the commandline written below..

rundll32 syssetup,SetupInfObjectInstallAction DefaultInstall 128 «c:\My Files\WDKsamples\scanner.INF»

When I right-click ->Install this file then driver gets installed and keeps the files to their respective paths.

Please help me . Thanks in Advanvce.

(* Driver is compiled as 64 bit and digital signature also. )

Ok, and what exactly is bad about using right-click to kick off an install? It’s easy to navigate too, and relatively intuitive as opposed to having to remember path and file name. You need to use a viable executable such as devcon, for which you also get the source, or write your own using the non-pnp example in the WDK. You may or may not need the installation of the WDF co-installer included in the non-pnp source.

Gary G. Little NanoTelesis Systems, LLC

Try: rundll32 SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 «c:\My Files\WDKsamples\scanner.INF»

I’ve learned a lot about this particular method. In short, starting in Vista, DefaultInstall sections will need to be platform specific if the platform is specific 🙂 DefaultInstalls which fail with «Installation Failed» will succeed if the section is decorated (e.g. DefaultInstall.amd64)

However, it should be understood, you can’t actually install a driver this way. DefaultInstall is a legacy method which will only (1) copy files and (2) create a service section. Nothing else (for the most part). Driver Installation is more complicated than this and indeed, DefaultInstall also has no concept of what a signed driver is and the CAT file will never be properly moved over the the CATDB. FYI (See: http://msdn.microsoft.com/en-us/library/ff547356(VS.85).aspx ) and

Note The INF file of a driver package must not contain an INF DefaultInstall section if the driver package is to be digitally signed. For more information about signing driver packages, see Driver Signing .

It’s better to use SetupDI to install drivers instead of this method.

Daniel Whitaker WDK Support Team

  • Proposed as answer by Emberstone Microsoft employee Thursday, March 10, 2011 6:50 PM
  • Unproposed as answer by markRoddy Thursday, March 10, 2011 7:20 PM
  • Marked as answer by Doron Holan [MSFT] Tuesday, January 8, 2013 7:53 AM

Actually this is the documented method for installing specific types of drivers, for example filesystem minifilters. The OP’s question was specific to minifilter installation.

where the exact method used by the OP is documented as appropriate to this type of driver.

«To execute the DefaultInstall and DefaultInstall.Services sections of your INF file on the command line or by using a batch file installation, type the following command at the command prompt, or create and run a batch file that contains this command:

RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 path-to-inf\infname.inf»

Mark Roddy Windows Driver and OS consultant www.hollistech.com

I’m sorry, but perhaps you could explain what you think the installation procedure is for a filesystem minifilter driver on Win7? As far as I know, ‘right click inf file’ or its equivalents are THE ONLY WAY, and yes your minifilter has to be signed for WIN7 x64. If there is some other mechanism, and if in fact installation as documented in the WDK does not work, perhaps you might want to update the WDK pages I pointed you at.

perhaps the confusion here is that we are not talking about pnp drivers?

Mark Roddy Windows Driver and OS consultant www.hollistech.com

Thanks Emberstone for clearing the things.

Actually I m going to install the driver by the proper way and having problem while copying the files to specific paths. ie.. ..\drivers Folder.

now I detected exac problem and noticed that it’s due to Access rights to the ‘drivers’ folder.

Thanks all , You all guys helped me a lot.

I’m getting this same issue but using SetupAPI. I’ve been wrestling with this issue for a month or two now and it’s driving me crazy. I’ve tried countless variants on the inf-file and the setupapi-calls but am just getting different issues without really moving forward. So this is what I have at the moment.

Files
myMinifilter.inf
myMinifilter.sys (signed)
myMinifilter.pdb
myMinifilter.cat (signed)

Installer
InstallShield 2010 InstallScript installer compiled for 64 bit release.

Target System
Windows Server 2008 R2 — 64bit ( Updated with all current OS-patches and IE9)

Code Procedure

Attempt to copy files using SETUPAPI.SetupCopyOEMInfA()
SUCCESS: myMiniFilter.inf copied to oem1.inf in Windows\inf dir, and driver package files to ‘C:\Users\ADMINI

WARNING: <_verify_file_signature>( in setupapi.dev.inf) failed with «Error 0x800b0109: A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.»

SETUPAPI.SetupOpenInfFileA() using returned inf-path from step 1.
SUCCESS

SETUPAPI.SetupQueueCopySectionA() using section “DefaultInstall” and the %windir%\inf path
SUCCESS: Looking at the setupapi.app.log it now has a couple of interesting lines:

Architecture = amd64 (Previously when the path was pointing to my souredir for the installer Architecture was = x86 So not due to IS being 32bit! Now this looks correct).

Two instances of «! flq: Missing SourceDisksFiles/SourceDisksNames information from INF.» in setupapi.app.log, I’ve tried messing with the inf-file quite a lot but to no avail, either the syntax is not supported by inf2cat.exe or I get warnings like these.

SETUPAPI.SetupCommitFileQueueA() with no callback specified.
FAILED with error 13 (The data is invalid).

Looking at setupapi.app.log the following error is posted: «. flq: The file queue callback routine faulted during commit with exception c0000005.»

  • SETUPAPI. SetupCloseFileQueue()
    SUCCESS
  • So as you can see pretty much the same a above, looks like a premissions issue but I am running the setup as Admin and there are no other issues (services are installed, accouts are validated, etc.) What am I missing?

    Читайте также:  Perfect viewer для windows
    Оцените статью
    Option/Argument Description