Installing an INF File Using a Windows Batch File

When you right-click on the .inf file, you have the Install option. I want to install a .inf file from the command line using a batch file. What is the β€œright” way to do this?

Thanks!

[edit] I must clarify that I am trying to run this on Windows XP (not Vista). Although I affirm (and voted) that InfDefaultInstall.exe is mentioned below, I believe that the program was not sent from XP.

+4
source share
3 answers

You can find the command while browsing the registry key HKCR\inffile\shell\Install\command . In Windows XP, this

  % SystemRoot% \ System32 \ rundll32.exe setupapi, InstallHinfSection DefaultInstall 132% 1 

in Windows Vista and later it will be

  % SystemRoot% \ System32 \ InfDefaultInstall.exe "% 1" 

To use the batch file in several versions of Windows, you will need several tricksters. You can use reg.exe to request a key and try parsing the output (I did not find a quick way to get only the value from reg ). If you know which platforms you use, you can also hardcode the command lines and switch according to the version of Windows (it will take a different hack to figure this out. %OS% does not tell you more than "Windows NT", unfortunately .).

+7
source
  rem tested / works

 : inf
 ver |  findstr / il "Version 6."  > nul 
 if% ERRORLEVEL% == 0 goto: vista

 : xp
 start / wait rundll32.exe setupapi, InstallHinfSection DefaultInstall 4% _%
 goto: eof
 : vista
 % SystemRoot% \ System32 \ InfDefaultInstall.exe "% _%"

 : eof
+2
source

Should work on any Windows system with IE 4.0+:

 RunDll32 advpack.dll,LaunchINFSection <file.inf>,DefaultInstall 
+1
source

All Articles