I was installing a driver over and over, and thought that there must be a better way than going to the device manager.  Well, it turns out that there is.

The plug and play utility (pnputil.exe) is designed for this purpose.   The following installs from an INF named mydriver.inf.

pnputil.exe -i -a "c:\OEM\mydrive.inf"

Which I included in the following batch file, which copies the driver to a folder on the C drive, installs the driver, then reboots if the user agrees.

@echo off

xcopy /s /e /q /Y /I OEM c:\OEM

pnputil.exe -i -a "c:\OEM\mydrive.inf"

echo.
echo.
echo A reboot is necessary for these changes to take effect.
echo.
set /p input= "Reboot Now (Y/N)?"

echo %input%
IF "%input%"=="y" goto :REBOOT
IF "%input%"=="Y" goto :REBOOT
goto :EOF

:REBOOT
shutdown /r /t 0

 

Copyright © 2015 – Bruce Eitman and Embedded101.com
All Rights Reserved