Adding .inf drivers using PowerShell, possible?
Asked Answered
D

5

6

Are we able to install drivers via their .inf files etc. using a PowerShell cmdlet? When Googling I found, Add-WindowsDriver but I think this one is for an offline Windows image. Does that mean an image that is not currently used on an OS? If not, please teach me how to write the parameters. Thank you!

Diffuse answered 21/10, 2016 at 14:59 Comment(5)
Start-Process -Path $PathToInf -Verb Install?Shipmaster
I just realize you can right click install .inf files, however, this .inf file says "The INF file you selected does not support this method of installation."Diffuse
How about using PNPUTIL? For example: pnputil.exe -i -a C:\example\example.INFPrincedom
Hi Benh, it gave me an error Failed to install: No more data is available I believe this is because the device already has an existing driver, I need to install these new drivers I have, how would I tell PS or CMD specifically to replace the existing drivers with this new one?Diffuse
You'll need to delete the old one first. So you'll need to enumerate all of the current drivers with pnputil.exe -e then find what it's named and then pnputil.exe -f -d oem0.inf (-f is force and may not be needed)Princedom
C
11

This PowerShell script will do what you want:

Get-ChildItem "C:\Driver File Location" -Recurse -Filter "*inf" | ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install } 
Clavate answered 24/5, 2018 at 18:10 Comment(0)
C
2

You don't need Powershell or advanced CMD programming, because pnputil.exe has a /subdirs command line switch and can slurp multiple .inf files at once. On my system (Windows 10 x64 21H2), you can simply execute:

pnputil /add-driver *.inf /install /subdirs

That does what I would expect.

pnputil.exe's help tells everything we need. Just execute pnputil without further parameters, and it outputs an understandable help screen (that is too long to post it here).

Cricket answered 17/11, 2022 at 1:38 Comment(0)
C
0

Reposting the comment (credit to @Bacon Bits), because it works.

Start-Process -$PathToInf -Verb Install

worked for me

Covering answered 27/2 at 16:31 Comment(0)
M
0

This one liner has always served me good for injecting drivers.

for /f "delims=" %%J in ('dir /b /s "c:\out-of-box-drivers\\*.inf"') do pnputil.exe -i -a "%%J%
Monk answered 23/5 at 17:1 Comment(0)
C
-1

It can be done using the Install-DeviceDriver cmdlet from the DeviceManagement module. See my answer here for an example.

Clinician answered 24/8, 2020 at 19:30 Comment(1)
This tool is no longer working properly.Isogloss

© 2022 - 2024 — McMap. All rights reserved.