How to make an app - Andromo App Maker


No announcement yet.

HOWTO: Detect Administrator Privileges

  • Filter
  • Time
  • Show
Clear All
new posts

  • HOWTO: Detect Administrator Privileges

    HOWTO: Detect Administrator Privileges

    HOWTO: Detect Administrator Privileges

    Document 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:

    • Administrators
    • Users
    Each type of user, or "User Group" has different privileges and access to different portions of the system. As a result it is often important to know which User Group your end user falls into, and the properties of each group.

    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
    Members of the "Users" group can:
    • Run programs installed by administrators
    • Access the files within their user profile
    • Modify their HKEY_CURRENT_USER registry settings
    So if your installation needs to modify a registry value found outside HKEY_CURRENT_USER, or if you want the program being installed to be accessible to all users on the computer you must make sure that your installation is run by a user with administrative privileges.

    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
    Conversely the following checks need to be made to determine that the user IS an Administrator:
    • They are running Windows NT, 2000, or XP
    • %IsUserNTAdmin% = TRUE
    In general it is easier to determine that the user is NOT an Administrator, simply because this makes it easy to include Windows 95 and 98 users, who will generally have "Administrator" privileges on their systems.


    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.
    If ((!%IsWindows95%) AND (!%IsWindows98%)AND(!%IsUserNTAdmin%))
    Show Message Box (You do not have administrative privileges. The setup will now Abort.)
    Abort Setup
    END IF
    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.


    For more information please see the following topics in the Setup Factory 6.0 Help:

  • Command Reference | Variables | Built-in Variables
  • Command Reference | Actions | Individual Actions | Abort
  • Command Reference | Actions | Individual Actions | END IF
  • Command Reference | Actions | Individual Actions | IF
  • Command Reference | Actions | Individual Actions | Show Message Box
  • 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.