ALLUSERS
The ALLUSERS system variable is the key to installations that allow installing the application to the current user or all users on the target system. The value of ALLUSERS determines the following:
• | The root key that is used by registry functions that are called after RegDBSetDefaultRoot(HKEY_USER_SELECTABLE) is called |
• | The root key under which the application uninstallation key is created |
• | The location of registry entries that are specified in a registry set’s HKEY_USER_SELECTABLE root key |
• | The value of the DISK1TARGET system variable (which specifies the path to the folder in which copies of certain installation files are placed to enable maintenance installations and uninstallation) |
• | The default value of the TARGETDIR system variable that is set by the default OnFirstUIBefore code |
• | Whether a shortcut that is defined in InstallShield with its Type property set to Automatic appears in the list of personal shortcuts or common shortcuts when the shortcut is created |
• | The default option selection in the SdCustomerInformation and SdCustomerInformationEx dialogs |
ALLUSERS has no effect on the registration of COM DLL files.
The following sections explain how the value of ALLUSERS is determined and set in different project types.
InstallScript Installations
If an installation is running as a first-time installation, the InstallScript engine determines during initialization the most appropriate value for the ALLUSERS variable and initializes it to that value:
• | If the user does not have administrator privileges, ALLUSERS is set to 0. This results in a per-user installation. |
• | Otherwise, ALLUSERS is set to 1. This results in a per-machine installation by default. |
If an installation is running in maintenance mode, the InstallScript engine determines the value of the ALLUSERS variable based on whether the initial installation was installed as per-user or per-machine (based on the location of where the uninstallation information was installed).
For an example of an InstallScript installation that allows installing the application to the current user or all users on the target system, see the sample project in the ALLUSERS Sample Project folder. This folder is a subfolder in the Samples folder of your InstallShield Program Files folder. The default location is:
C:\Program Files\InstallShield\2021\Samples\InstallScript\ALLUSERS Sample Project
InstallScript Custom Actions in Basic MSI and InstallScript MSI Installations
Getting the Value of the ALLUSERS Variable
The ALLUSERS InstallScript variable is determined by querying the Windows Installer property ALLUSERS:
Windows Installer Property |
InstallScript Variable |
Notes |
"" |
0 |
Any per-user or per-machine dependent script code in the custom action results in per-user behavior. |
1 |
1 |
Any per-user or per-machine dependent script code in the custom action results in per-machine behavior. |
Any other value |
The InstallScript engine attempts to determine the appropriate value. |
|
If the Windows Installer property ALLUSERS cannot be determined because the InstallScript engine determines that a deferred custom action is running, an unexpected property value is returned, or MSIGetProperty returns an error value. Therefore, the InstallScript engine attempts to determine the best value for the variable.
Note that the InstallScript engine uses MsiGetMode with the MSIRUNMODE_SCHEDULED, MSIRUNMODE_ROLLBACK, and MSIRUNMODE_COMMIT flags to determine if a deferred custom action is running. If MsiGetMode returns true for any of the above values, the custom action is assumed to be deferred and the InstallScript mechanism is used.
Note that if a Basic MSI installation does not have a value for ALLUSERS in the Property table, any InstallScript custom action that runs before the installation displays an ALLUSERS dialog (such as the CustomerInformation dialog, which sets the ALLUSERS Windows Installer property) has the ALLUSERS InstallScript variable set to 0. Therefore, the InstallScript custom action exhibits per-user behavior. Thus, it is recommended that all Basic MSI installations have a default value for ALLUSERS in the Property table.
Setting the Value of the ALLUSERS Variable
When the ALLUSERS InstallScript variable is set in script, the InstallScript engine first determines whether the platform and privilege level allow the ALLUSERS InstallScript variable to be changed. (In scenarios where the end user is not an administrator or power user, ALLUSERS cannot be changed.)
If the ALLUSERS InstallScript variable can be changed, the InstallScript engine attempts to update the ALLUSERS Windows Installer property appropriately as follows:
InstallScript Variable |
Windows Installer Property |
1 |
1 |
0 |
"" |
Note that the InstallScript engine sets the ALLUSERS InstallScript variable even if the Windows Installer property cannot be set. This could result in synchronization problems between the Windows Installer property and the InstallScript variable. Therefore, if you change the ALLUSERS InstallScript variable in a custom action, it is recommended that you set the Windows Installer property manually as well to ensure that the property can be changed successfully.
The following table shows the behavior for various scenarios on Windows Vista with User Account Control (UAC) enabled.
Type of Custom Action |
Manifest |
ALLUSERS Value in Property Table |
Windows Installer Property |
Resulting InstallScript Variable |
Notes |
Immediate |
Highest available |
2 |
1 |
1 |
|
Immediate |
Invoker |
2 |
"" |
0 |
The InstallScript variable cannot be changed. Per-machine InstallScript actions are not possible. |
Immediate |
Highest available |
1 |
1 |
1 |
|
Immediate |
Invoker |
1 |
1 |
1 |
The InstallScript variable cannot be changed. Per-machine InstallScript actions fail. |
Immediate, before CustomerInformation dialog (or end user selects to install per user) |
Invoker |
"" |
"" |
0 |
The InstallScript variable cannot be changed. Per-machine InstallScript actions are not possible. |
Immediate, after CustomerInformation dialog |
Highest available |
"" |
1 |
1 |
|
Deferred |
Invoker |
Any |
Cannot be determined |
0 |
The InstallScript variable cannot be changed. InstallScript method for determining ALLUSERS is used. |
Deferred |
Highest available |
Any |
Cannot be determined |
1 |
InstallScript method for determining ALLUSERS is used. |
The following table shows the behavior for various scenarios on pre-Windows Vista systems and on Windows Vista systems with User Account Control (UAC) disabled.
Type of Custom Action |
User Privileges |
ALLUSERS Value in Property Table |
Windows Installer Property |
Resulting InstallScript Variable |
Notes |
Immediate |
Administrator |
2 |
1 |
1 |
|
Immediate |
Limited |
2 |
"" |
0 |
The InstallScript variable cannot be changed. |
Immediate |
Administrator |
1 |
1 |
1 |
|
Immediate |
Limited |
1 |
1 |
1 |
The InstallScript variable cannot be changed. The installation fails during UI sequence, and per-machine InstallScript custom actions fail. |
Immediate, before CustomerInformation dialog (or end user selects to install per user) |
Administrator |
"" |
"" |
0 |
The InstallScript variable cannot be changed. Per-machine InstallScript actions are not possible. |
Immediate, after CustomerInformation dialog |
Administrator |
"" |
1 |
1 |
|
Deferred |
Administrator |
Any |
Cannot be determined |
1 |
InstallScript method for determining ALLUSERS is used. |
Deferred |
Limited |
Any |
Cannot be determined |
0 |
The InstallScript variable cannot be changed. InstallScript method for determining ALLUSERS is used. |
Any on Windows 9x |
Not applicable |
Any |
Any |
1 |
The InstallScript variable cannot be changed. InstallScript method for determining ALLUSERS is used. |
If the resulting InstallScript variable is 0, InstallScript custom actions are used in a per-user context. If the resulting InstallScript variable is 1, InstallScript custom actions are used in a per-machine context.
Event-Driven InstallScript Code in InstallScript MSI Installations
InstallScript MSI installations work similarly to InstallScript installations except that when the ALLUSERS InstallScript variable is changed, the installation attempts to update the Windows Installer property ALLUSERS as described for InstallScript custom actions.
During InstallScript MSI installations, the Windows Installer property ALLUSERS is not queried to determine the appropriate value of the ALLUSERS InstallScript variable; the InstallScript engine always attempts to determine the value, as described for InstallScript installations.