02-17-2021 06:01 PM - edited 02-17-2021 06:04 PM
Greetings,
I built an installer which calls a .bat file. The bat file is supposed to install a device-driver using "pnputil.exe". When the installer calls the .bat file, the pnputil command fails with a DOS "command not found" error. If I merely double-click on the same bat file, it runs correctly.
It seems to be a privileges issue, but why wouldn't the .bat run with the same privilege as the caller?
I have Admin privileges when I run the installer (setup.exe). In an attempt to confer elevated privileges upon the .bat, I tried using "run as administrator" to run setup.exe, but always the same result.
The command looks like this:
"C:\Windows\System32\pnputil.exe /add-driver "%MyDir%%MyInfName%" /install"
I've seen other discussions related to running an exe with elevated privileges, even one about running a bat and command-not-found (that thread blamed OS "bitness"), but it wasn't clear to me whether there was a simple solution.
I'm running LabVIEW 2019 under 64bit Win10 Pro
Any ideas are welcome!
Solved! Go to Solution.
02-18-2021 12:23 AM - edited 02-18-2021 12:24 AM
Sorry misread your post. Nothing to see here.
02-21-2021 02:44 AM
It turns out it was a "bitness" issue and a convoluted relationship between the bitness of the .bat caller, and the "system" path to pnputil.
if exist %SystemRoot%\System32\pnputil.exe (
set "SystemPath=%SystemRoot%\System32"
) else if exist %SystemRoot%\Sysnative\pnputil.exe (
set "SystemPath=%SystemRoot%\Sysnative"
) else (
echo ERROR: Cannot find pnputil.exe to install the driver.
echo/
pause
goto :EOF
)
%SystemPath%\pnputil.exe -i -a "%USERPROFILE%\Desktop\Drivers\IPEnabled_001.inf"