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!
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 }
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).
Reposting the comment (credit to @Bacon Bits), because it works.
Start-Process -$PathToInf -Verb Install
worked for me
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%
It can be done using the Install-DeviceDriver
cmdlet from the DeviceManagement module. See my answer here for an example.
© 2022 - 2024 — McMap. All rights reserved.
Start-Process -Path $PathToInf -Verb Install
? – Shipmasterpnputil.exe -i -a C:\example\example.INF
– PrincedomFailed 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? – Diffusepnputil.exe -e
then find what it's named and thenpnputil.exe -f -d oem0.inf
(-f is force and may not be needed) – Princedom