22

I am working in Windows 8.1. I need to install a driver file (.inf file) from command line. Which command do I need to use?

I know I have many other method for installing a .inf file, but I must install this from command line.

Please help me Thanks in advance...

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
yemans
  • 917
  • 3
  • 12
  • 17

3 Answers3

19

Granger's comment works in Windows 7 too. According to MS, PnPUtil (PnPUtil.exe) is included in every version of Windows, starting with Windows Vista.

It is useful for device drivers that do not have default install (right-click "Install" does not work for them).

pnputil -i -a <driverinf>

Roland Pihlakas
  • 4,246
  • 2
  • 43
  • 64
16

The default way for device drivers is:

pnputil -i -a <driverinf>

Legacy Drivers can´t be installed with pnputil and have to use LaunchINFSectionEx-Call

I tested the following and it works with several drivers from Windows 2000 up to Windows 10, 2012R2, 2016, 2019.

rundll32.exe advpack.dll,LaunchINFSectionEx ykmd.inf,Yubico64_Install.NT,,4,N

Pay attention to use the correct section

The correct section of the inf-File must be used, when there is no [DefaultInstall]-Section. This lacks in most answers. Look it up in your drivers inf-File and use the correct section (in my example "Yubico64_Install.NT"). Using the wrong section wont prompt an error. Im my example I use Quiet mode, no UI (4) and Never reboot (N) to install the driver automated via GPO. All options are documented in detail here:

https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768006(v%3Dvs.85)

x0nn
  • 306
  • 1
  • 3
  • 7
2

There are many variants ... and many complications with newer versions of Windows.

But for starters, try something like this:

rundll32.exe advpack.dll,LaunchINFSectionEx myinf.inf,,c:\temp\mydata.cab,36

Note: beware older links that suggest "setupapi" instead of "advpack". You definitely want advpack.dll.

Community
  • 1
  • 1
FoggyDay
  • 11,962
  • 4
  • 34
  • 48
  • What about 64-bit Windows? Is it rundll64.exe? – mojuba Sep 26 '14 at 11:38
  • 1
    There's no such thing as "rundll64.exe". Q: Did you try "rundll32"? What happened? – FoggyDay Sep 26 '14 at 20:38
  • Not yet, but I know that lower-level APIs for driver installation require the main exe to be 32 or 64-bit depending on the host system. I'm trying to install a driver programmatically: http://msdn.microsoft.com/en-us/library/windows/hardware/ff541255(v=vs.85).aspx – mojuba Sep 26 '14 at 23:22
  • 1
    Speaking of newer versions of Windows. In [Hyper-V Server 2012 r1 & r2](https://technet.microsoft.com/en-us/jj647787(v=ws.11).aspx), the command-line is: `pnputil -i -a ` – Granger Sep 29 '16 at 03:48