How can I determine whether the user installing the .MSI has NTFS administrative privileges, and if so, how can I abort the installation?
You can determine if the user running your installation has administrative privileges by using the AdminUser property. If the user does not have administrative privileges, you can create a condition to abort the installation.
The property AdminUser is set automatically by the Windows Installer service on all Windows Operating Systems (Windows NT and newer) if the user has administrator privileges. This property is always set on Windows 95, Windows 98 and Windows ME. If it is determined that the user has administrative rights, the property AdminUser is set to 1. Otherwise, the value remains Null.
These values can be used as conditions for individual feature or components. Please see the linked article "How to build a condition to determine if a feature will be installed", for information on creating conditions for features.
Use the AdminUser property to set a Launch Condition for the .MSI installation. If AdminUser is True (has a value of 1), the installation will proceed. If AdminUser is False, a message will be displayed to inform the user of the need to have administrative rights.
To set this Launch Condition:
1. Open the Launch Condition page from the Product tab in Setup Editor.
2. Right-click on the Launch Conditions page and then select New-->Launch Condition.
3. Complete the Launch Condition Details dialog as follows:
* Property names are case sensitive; make sure to input the characters with an upper case "A" and "U". The AdminUser property will be created at runtime by the Windows Installer service if the user has Admin privileges. Otherwise, the AdminUser property will not exist.
Message Text: You must have Administrative rights to run this installation.
* Input a message to display to the user if the Launch Condition is not met. The Windows Installer service requires a message to be displayed.
4. Click OK on the Launch Conditions Details dialog to save the launch condition.
At runtime, AdminUser will be evaluated and the installation will be allowed to proceed if the user has NTFS administrative privileges. If the user does not have administrative privileges, then the installation will be halted. AdminUser is a valuable property that can be used as a condition to control installation of resources on a feature or component level or used to conditionally install an entire program.