HOWTO: Detect Administrator PrivilegesDocument ID: IR02010
The information in this article applies to:
- Setup Factory 6.0
- Setup Factory 5.0
The article explains how to determine if the end user has administrative privileges.
In general there are two main types of users on Windows NT-based operating systems (Windows NT 4.0, Windows 2000, and Windows XP), these are:
The first, and most powerful group is the "Administrators". This group has access to the entire operating system, they are not limited to which registry keys they can edit, files the can modify, or what types of programs they can run. In general, users with Administrative privileges will be the users installing programs.
The most common, and restricted, group is the "Users" group. This group is made up of the people who work with the computer on a day-to-day basis. They only need access to certain programs and data files found on their local system or network. These users have restricted access to the operating system and the registry. The basic Users group grants people access the computer without giving them the ability to do damage to: the operating system, installed programs, important documents, or other security measures that may be place.
Members of the "Users" group cannot:
- Modify system wide registry settings
- Modify Operating System files
- Install programs accessible to other users
- Run programs installed by administrators
- Access the files within their user profile
- Modify their HKEY_CURRENT_USER registry settings
To make this check easy, Setup Factory has a built-in variable:
%IsUserNTAdmin% - This variable is set to "TRUE" if the user running the setup is currently logged into Windows NT/2000/XP with Administrator privileges. It's set to "FALSE" otherwise. On systems that aren't running some version of Windows NT, this variable is always set to "FALSE".
So when checking to make sure that your user is NOT an Administrator two checks have to be made:
- They are not running Windows 95 or Windows 98
- %IsUserNTAdmin% = FALSE
- They are running Windows NT, 2000, or XP
- %IsUserNTAdmin% = TRUE
Here is some Setup Factory 6.0 pseudo-code that will determine if the end user is an Administrator or not. If the user is an Administrator the installation will continue, if they are not a Message box will appear informing them of this and then the installation will abort.
A good place to put these actions is on the "After" event of your first visible screen. That way the user will at least see the first screen of the installation before being forced to abort. Keep in mind that if you do not want to put the actions on the "After" event of your first visible screen you could place them anywhere, but make sure to do so before you attempt any actions that may not be possible for someone with User privileges.
If ((!%IsWindows95%) AND (!%IsWindows98%)AND(!%IsUserNTAdmin%))
Show Message Box (You do not have administrative privileges. The setup will now Abort.)
For more information please see the following topics in the Setup Factory 6.0 Help:
KEYWORDS: Setup Factory, %IsUserNTAdmin%, User, Administrator, Windows NT, Windows 2000, Windows XP, Privileges
Last reviewed: October 8, 2002
Copyright © 2002 Indigo Rose Corporation. All rights reserved.