I'm trying to install an .inf file via NSIS like (Installing a driver in NSIS script).
Installation itself works smooth, but Windows installs the driver with its internal published name (an incrementing number oemxxx.inf).
How can I get pnputil.exe to give me the published name as return value (for later usage)?
To run PnPUtil, open a Command Prompt window (Run as Administrator) and type a command using the following syntax and parameters. Note PnPUtil (PnPUtil.exe) is included in every version of Windows, starting with Windows Vista (in the %windir%\system32 directory). PNPUTIL [/add-driver <...> | /delete-driver <...>
Solution: Updating Drivers Using Command Prompt. *Note – Command Prompt method will not get the driver package from the web. You will have to download the driver package on your own by visiting the OEM website or by simply transferring it to your computer using a pen drive or any other form of external storage media.
What I did to get the published drivername in nsis is this hell of a workaround:
pnputil /e > driverlist_before.txt
pnputil /i /a mydriver.inf
pnputil /e > driverlist_after.txt
nsExec
content of GetPublishedDrivername.cmd
@echo off
:: look at differences between files and just keep the line with the oem info
fc mydriverlist_before.txt mydriverlist_after.txt | findstr /C:"oem" > diff.txt
:: cut result and keep second part " oem##.inf"
for /f "tokens1,2 delims=:" %%a in (diff.txt) do (
if "%%a"=="Published name " set info=%%b
)
:: get rid of leading spaces "oem##.inf"
for /f "tokens=* delims= " %%a in ("%info%") do set info=%%a
:: split "oem##.inf" and keep first part "oem##"
for /f "tokens=1,2 delims=." %%a in ("%info%") do set info=%%a
:: get of the oem part "##"
set info=%info:oem=%
:: convert string into int value
set /a info=%info%
del diff.txt
:: return number as result
exit /b %info%
This script can surely be optimized, every input is welcome.
I think that is not possible. Here is a list of all commands of PnPUtil:
Microsoft PnP Utility
pnputil.exe [-f | -i] [ -? | -a | -d | -e ]
Examples:
pnputil.exe -a a:\usbcam\USBCAM.INF -> Add package specified by USBCAM.INF
pnputil.exe -a c:\drivers*.inf -> Add all packages in c:\drivers\
pnputil.exe -i -a a:\usbcam\USBCAM.INF -> Add and install driver package
pnputil.exe -e -> Enumerate all 3rd party packages
pnputil.exe -d oem0.inf -> Delete package oem0.inf
pnputil.exe -f -d oem0.inf -> Force delete package oem0.inf
pnputil.exe -? -> This usage screen
So you cannot extract that information and pass it to NSIS easily :(
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With