Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to automate the PnP driver installs for Windows 7 with either of the below batch files via For loop and wildcard for the .inf file.

The rundll32 batch reads and echos the correct .inf file but then gives me the "Error Installation failed" and with the pnputil batch it runs without any error put does not install.

How can I correct the batch files to install the inf correctly?

@echo off&color a&setlocal enabledelayedexpansion
cd %~dp0

set PnP=rundll32 syssetup,SetupInfObjectInstallAction DefaultInstall 128 .\*.inf
for /f "delims=" %%a in ('dir/b %PnP%') do (
echo == Installing PnP Drivers == "%%a"
set PnP=pnputil -i -a "*.inf"
for /f "delims=" %%a in ('dir/b %PnP%') do (
echo == Installing PnP Drivers == "%%a"

ping -n 3 localhost 1>nul
start "" /wait %PnP%\%%a
echo. * DONE *
share|improve this question

1 Answer 1

After tweaking and testing got this working now – I am posting my code that hopefully may help someone else in the future that needs a fast and convenient way to reinstall all their drivers.

Tested and Working on Windows 7 and Windows 8 with 25+ driver installs in just over 1 minute.

@echo off&color a && Title [ MULTI .INF INSTALLER ]

::= Multi-PnP.Installer.cmd =
:: Put all Pnf, Infs, Cat, Sys files etc.
   together in same directory.

:: Run Batch From Current Directory 
cd %~dp0

:: Scan and Echo .inf files during install
for /f "delims=" %%a in ('dir/b *.inf') do (
echo == Installing PnP Drivers == "%%a"

:: Delay
ping -n 4 localhost 1>nul

:: Windows Plug Play Installer
start "" pnputil -i -a %%a
echo. * DONE *
echo == Reboot To Finalize Driver Installs! ==&pause>nul
share|improve this answer
I've merged your accounts for now, but in the future please log into Stack Exchange before posting an answer as an unregistered user. Now your accounts are associated and you can accept your own answer in a little less than two days. Cheers! –  slhck Oct 9 '12 at 16:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.