Before we can troubleshoot this behavior, we need to confirm that your executable or batch file is functional on its own. Run your executable or batch file separately from your LabVIEW installer and ensure that it executes without error - if it still gets an error, then there is likely an error in your syntax in your file that you need to identify. If it does execute without error, there are a few steps we can take to narrow down the cause of the behavior:
- It's possible that this error is appearing because your post-installer action isn't being run with administrator privileges, even if your LabVIEW installer is. To ensure that your post-installer action executes with administrator privileges:
- When running your LabVIEW installer, right-click the installer and select Run as Administrator to ensure that the installer is being run with administrator privileges.
- Encapsulate your post-installer action in a call to the Windows API using the Call Library Function Node to explicitly call your executable or batch file with administrator privileges - an example using the Notepad program is shown below.
You can build the VI which performs this functionality into an executable, and call this "wrapper executable" instead of the post-action executable or batch file that you'd like to call.
- If the issue persists after calling the executable explicitly as an administrator, then the issue is likely due to Windows rather than LabVIEW. One potential cause to look out for is being unable to find pnputil.exe due to the bitness of your program - pnputil.exe only exists as a 64-bit application on 64-bit Windows, so if your installer is a 32-bit application, it may not be able to find pnputil.exe due to the default directory for your application not containing pnputil.exe - this is explained in more detail on this StackOverflow page. If you're using a batch file, you can ensure that pnputil.exe is correctly detected by including the following snippet of code before executing your calls to pnputil.exe:
if exist %SystemRoot%\System32\pnputil.exe (
) else if exist %SystemRoot%\Sysnative\pnputil.exe (
) else (
echo ERROR: Cannot find pnputil.exe to install the driver.
%SystemPath%\pnputil.exe -i -a "%USERPROFILE%\Desktop\Drivers\IPEnabled_001.inf"