Installing a .inf file using a windows batch file

后端 未结 3 1867
轻奢々
轻奢々 2021-02-10 10:45

When you right click on a .inf file you have an option to \"Install\". I want to install a .inf file from the command line using a batch file. What is the \"right\" way to do th

相关标签:
3条回答
  • 2021-02-10 11:25
    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
    
    0 讨论(0)
  • 2021-02-10 11:36

    Should works on any Windows system that has IE 4.0+:

    RunDll32 advpack.dll,LaunchINFSection <file.inf>,DefaultInstall
    
    0 讨论(0)
  • 2021-02-10 11:42

    You can find the command when looking at the HKCR\inffile\shell\Install\command registry key. On Windows XP this is

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

    on Windows Vista and later this would be

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

    To use the batch file across several Windows versions you would need some trickery. You could use reg.exe to query for the key and try parsing the output (I didn't find a quick way of getting only the value from reg). If you know what platforms you're running on you could also hard-code the command lines and switch according to the Windows version (which would need another hack to find that out. %OS% doesn't tell you more than "Windows NT", unfortunately.).

    0 讨论(0)
提交回复
热议问题