09-19-2019 10:56 AM - edited 09-19-2019 11:34 AM
Hi everyone,
I have a LabVIEW 17 built application for which I have created an installer for a Win10 machine. As part of the installation process, I would like to automatically install some drivers without having to go through the Device Manager. Furthermore, these drivers cannot be installed by doing a Right-Click install of the .inf file.
After installation, it appears I can specify only an EXE or a BAT file (I am using BAT) to run. I cannot run a shortcut (which can be set to run as an administrator), because the installer replaces the shortcut with the executable it points to. So, I am trying a batch file approach.
Even if I run the Installer's Setup.exe as an administrator, the installer does not run the cmd shell as an administrator. I have verified that when I run cmd as an administrator (from outside the installer process), I can execute the following commands successfully to install the drivers using the .inf files:
pnputil.exe /i /a driver1.inf
pnputil.exe /i /a driver2.inf
However, when I put these in my batch file to run in the installer, the pnputil.exe is not recognized as an executable. I am assuming that is because cmd is not being run as an administrator. I am also able to create a shortcut to this batch file on my desktop, set it to run as administrator, and when I double-click on it the batch file installs the drivers successfully.
I've been trying six ways from Sunday to make this work from the LabVIEW installer. Can anyone provide any suggestions?
Thanks
09-19-2019 11:55 AM
You could just write your own executable that makes the correct calls, but requests the calls be run as admin.
See this post on how to use Shell32 to run commands as admin from a program.
09-19-2019 12:22 PM
Thanks, BowenM.
I had seen that, but I was really trying to avoid writing another LabVIEW program to do something I should be able to do from a batch file or a shortcut file. My batch file contains additional commands in it, not just those two, and writing a LabVIEW app to do everything just seems like an extremely cumbersome method. It seems like the LabVIEW installer should be able to determine whether Setup is being run with administrator privileges, and execute the batch file by running cmd as an administrator.
I'm not sure why NI hasn't given us a way to easily do this using options built into the installer.