LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

My installer calls a .BAT file, but a command isn't found

Solved!
Go to solution

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!

 

0 Kudos
Message 1 of 3
(2,353 Views)

Sorry misread your post.  Nothing to see here.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 3
(2,315 Views)
Solution
Accepted by topic author 550nm

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"

 

0 Kudos
Message 3 of 3
(2,260 Views)