InstallShield 2016 » InstallScript Language Reference
The SetObjectPermissions function is used to set permissions for a file, a folder, or a registry key. The file, folder, or registry key can be installed as part of your installation, or it can be already present on the target system.
Syntax
SetObjectPermissions (byval string szObject, byval number nType, byval string szDomain, byval string szUser, byval number nPermissions, byval number nOptions);
Parameters
Parameter |
Description |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
szObject |
Specify the object (file, folder, or registry key) for which you want to set permissions. For files and folders, specify the full path. For registry keys, use one of the following in the path:
The following example set permissions for a key in HKEY_LOCAL_MACHINE: SetObjectPermissions("MACHINE\\Software\\MyProduct\\Example", IS_PERMISSIONS_TYPE_REGISTRY, "", "Users", KEY_CREATE_SUB_KEY, IS_PERMISSIONS_OPTION_DENY_ACCESS); |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nType |
Indicate the type of object that is being passed through the szObject parameter. Valid options are:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
szDomain |
Specify the domain name of the user for which permissions are being set. To use the local machine as the domain, pass an empty string ("") for this parameter. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
szUser |
Specify the name of the user for which permissions are being set. Available options are:
The user can be one that is being created during the installation, or one that already exists on the target system at run time. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nPermissions |
To specify the permissions that are to be applied to the object for the specified user, pass one of the following predefined constants in this parameter. You can combine these constants by using the bitwise OR operator ( | ). Available options are:
The following options are applicable to files and folders:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nPermissions (cont.) |
The following options are applicable to registry keys:
For information on each value, see “Registry Key Security and Access Rights,” “File Security and Access Rights,” and “Registry Key Security and Access Rights” in the MSDN Library. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nOptions |
Pass one or more of the following predefined constants in this parameter.
You can combine more than one constant by using the bitwise OR operator ( | ). The IS_PERMISSIONS_OPTION_DENY_ACCESS and IS_PERMISSIONS_OPTION_ALLOW_ACCESS constants should not be combined because they are mutually exclusive; if you specify both of these options for nOptions, permissions are denied. |
Return Values
Return Value |
Description |
ISERR_SUCCESS |
The function successfully set the permissions. |
!= ISERR_SUCCESS |
The function could not set the permissions. The return value is a Win32 error. For documentation on Win32 errors, see the MSDN Library. |
Additional Information
SetObjectPermissions attempts to set permissions on a 64-bit key if the REGDB_OPTION_WOW64_64KEY option is enabled.
To set permissions for files that are in the 64-bit System32 folder, file system redirection should be disabled before the SetObjectPermissions function is called. To disable file system redirection, use the WOW64FSREDIRECTION constant, as shown in the following code:
Disable (WOW64FSREDIRECTION);
Once the operation is done, disable file system redirection:
Enable(WOW64FSREDIRECTION);
See Also
Securing Files, Folders, and Registry Keys in a Locked-Down Environment
InstallShield 2016 Help LibraryMay 2017 |
Copyright Information | Flexera Software |