0

I have a directory which contains hundreds of other child directories, which all contain various INF files which I've extracted from a .CAB file.

I want to create a batch file that finds every single inf file in this directory and install it.

Code so far:

for /f %f in ('dir /s /b c:\temp_dir\*.inf') do rundll32 syssetup,SetupInfObjectInstallAction DefaultInstall 128 %f

In return, I get a critical message box appear hundreds of times saying "Installation failed". Please can someone point out my mistake because I'm completely stumped.

Environment: Windows 7 x64

Thanks in advance!

user3122456
  • 43
  • 1
  • 8
  • Drivers should be installed with [DPInst](http://msdn.microsoft.com/en-us/library/windows/hardware/ff544775.aspx) which is a free tool of Microsoft to install driver packages available as `dpinst32.exe` and `dpinst64.exe`. For example to install all the drivers for a WLAN adapater consisting of several *.inf and *.sys, all driver files which belong together must be put into a directory (default) and just executing appropriate `dpinst*.exe` in this directory results in a successful installation of ONLY the WLAN driver files without additional software. – Mofi Aug 09 '14 at 10:28
  • It is possible to install with this method just the drivers without the additional software nearly never really needed for nearly all driver install packages shipped with additional software. Of course `dpinst*.exe` is written for driver packages and not for installing applications with *.inf files and can (should) be therefore not used for installing applications. – Mofi Aug 09 '14 at 10:31

1 Answers1

0

Use %%f in a batch file. You use %f at the cmd prompt, with a for loop.

Additionally, if the current directory is not c:\temp_dir then it needs to be added to the final term.

@echo off
for /f "delims=" %%f in ('dir /s /b "c:\temp_dir\*.inf" ') do rundll32 syssetup,SetupInfObjectInstallAction DefaultInstall 128 "c:\temp_dir\%%f"

EDITED: Different method to make the directory current and with "delims=" added (above too)

@echo off
cd /d "c:\temp_dir\"
for /f "delims=" %%f in ('dir /s /b *.inf ') do rundll32 syssetup,SetupInfObjectInstallAction DefaultInstall 128 "%%f"
foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • Thanks for this info. This now works, but I'm getting "Installation Failed" appearing in a critical dialog box for all my INF files. Any ideas why? - These drivers work fine when installed manually. The only thing that comes to mind is that the folder that the INF is sitting in has other files with it which the INF file could be referencing. Could that be the problem? – user3122456 Aug 11 '14 at 03:38
  • Try the edited code above - it also has `"delims="` to handle long filenames. – foxidrive Aug 11 '14 at 06:32
  • Thank you for your response. Sadly this hasn't worked either. Same result. – user3122456 Aug 11 '14 at 16:19
  • Does your `rundll32` command line work with a single `.inf` file? – foxidrive Aug 11 '14 at 20:48
  • Strangely, no. However they all work manually if you specify the INF in a device manager wizard. The cabinet file in question is at the following UR: http://en.community.dell.com/techcenter/enterprise-client/w/wiki/2180.latitude-e6320-windows-7-driver-cab.aspx – user3122456 Aug 13 '14 at 17:38
  • If it's not correct then the batch file ain't going to work wither :D – foxidrive Aug 14 '14 at 01:46
  • Used `for /f "delims=" %%f in ('dir /s /b *.inf ') do pnputil /a "%%f" /i` to fix the "Installation Failed" error. – The.Power.Process Dec 22 '20 at 18:00