Developer Center Resources

Showing results for 
Search instead for 
Did you mean: 

Checking LabVIEW Administrator Privileges

In some instances, installing an add-on may require the user to run LabVIEW as an administrator. Without the proper checks, the installation of an add-on may fail, which can even go unnoticed at first. By determining if LabVIEW has administrator privileges, the developer of an add-on can take the appropriate actions necessary, such as aborting the installation and prompting the user to restart LabVIEW as an administrator.


An example of this check can be seen if one tries to install NI's Third Party Licensing and Activation Toolkit without Administrator privileges through VI Package Manager:



VIPM TPLAT Error.png



This package used a pre-install VI to check for administrator privileges and generated an error when it was determined that it did not have sufficient admin rights.  


An attempt is made to write a temporary file to a directory (or create the directory if it does not exist) that requires administrator privileges. If the attempt is unsuccessful, an error is generated, thus preventing the installation from continuing.


Use the attached VIs as example.

Rick C.
Download All

This VI doesn't work for LabVIEW 64-bit, because in that case the "_Legal Information" folder doesn't exist.

The code then tries to create the folder but immediately deletes it, causing the writing to file to fail with error 7.


Instead I would propose that:

* If folder doesn't exist, try to create it, if that fails we are not admin

* If folder exist, try to write file, if that fails we are not admin


Basically this means that the file write test should go in the TRUE case after we check if folder exists


NI Employee (retired)
Updated the example VIs based on this feedback.
Matt J - NI Tools Network