File.SetPermissions

number File.SetPermissions ( 

string Filename,

string UserSID = SID_EVERYBODY,

number AccessMode = SET_ACCESS,

number Permissions = ALL_PERMISSIONS,

number Inheritance = SUB_CONTAINERS_AND_OBJECTS_INHERIT )

Description

Sets the permissions of a file or folder.

Parameters

Filename

(string) The full path to the file or folder whose permissions will be set.

UserSID

(string) The SID of the user or group whose permissions will be altered. You may use any valid string or choose from the following built-in SID constants:

Tip: You can also use the System.GetUserSID action to get the SID value from a username on the local computer.

CONSTANT

VALUE

DESCRIPTION

SID_NULL

"S-1-0"

A NULL authority.

SID_NOBODY

"S-1-0-0"

Nobody.

SID_EVERYBODY

"S-1-1-0"

Everyone, a group that contains all users except for anonymous users on all systems greater than or equal to Windows XP SP2.

SID_CREATOR_AUTHORITY

"S-1-3"

An identifier authority representing the creator authority.

SID_CREATOR_OWNER

"S-1-3-0"

The current owner of the file object.

SID_NETWORK

"S-1-5-2"

A group containing all users that have logged on using a network connection.

SID_AUTHENTICATED_USERS

"S-1-5-11"

A group containing all users that were authenticated when they logged on.

SID_ADMINISTRATORS

"S-1-5-32-544"

The built-in administrators group.

SID_USERS

"S-1-5-32-545"

The built-in users group.

SID_GUESTS

"S-1-5-32-546"

The built-in guests group.

SID_POWER_USERS

"S-1-5-32-547"

The built-in power users group.

SID_LAUNCH_USER_USER

"LaunchUser"

The user who launched the setup. This is the same user whose information is used to populate the launch user variables.

AccessMode

(number) Controls how the permissions will be applied. Choose from:

Note: This value can also be any of the available access modes available in the ACCESS_MODE enumeration: http://msdn.microsoft.com/en-us/library/aa374899(VS.85).aspx

CONSTANT

VALUE

DESCRIPTION

NOT_USED_ACCESS

0

Not used.

GRANT_ACCESS

1

Combines the new permissions with the existing permissions for the user or group.

SET_ACCESS

2

Set the permissions for the user or group overriding any existing information.

DENY_ACCESS

3

Deny the user the permissions specified, this will not override any existing denied rights.

REVOKE_ACCESS

4

Remove any existing privileges for the user or group.

Permissions

(number) The permissions that will be used by the actions. Choose from one of the following or specify your own valid value:

Note: Please see: http://msdn.microsoft.com/en-us/library/aa446627%28VS.85%29.aspx for more information.

CONSTANT

VALUE

DESCRIPTION

READ_PERMISSIONS

1179785

Read permissions.

WRITE_PERMISSIONS

1179926

Write permissions.

EXECUTE_PERMISSIONS

538050697

Read and Execute permissions.

ALL_PERMISSIONS

268435456

Full control permissions.

MODIFY_PERMISSIONS

1245631

Modify (includes Read, Write, and Execute) permissions.

READ_WRITE_PERMISSIONS

1180063

Read and Write permissions.

READ_WRITE_EXECUTE_PERMISSIONS

538050975

Read, Write, and Execute permissions.

Inheritance

(number) The inheritance rules for the permissions that will be applied. Choose from, or specify a valid value:

Note: Please see: http://msdn.microsoft.com/en-us/library/aa446627%28VS.85%29.aspx for more information.

CONSTANT

VALUE

DESCRIPTION

NO_INHERITANCE

0

The permissions are not inheritable.

SUB_OBJECTS_ONLY_INHERIT

1

Only non-container objects within the file object will inherit the permissions.

SUB_CONTAINERS_ONLY_INHERIT

2

Only container objects within the file object will inherit the permissions.

SUB_CONTAINERS_AND_OBJECTS_INHERIT

3

Both objects and containers that are contained by the file object will inherit the permissions.

INHERIT_NO_PROPAGATE

4

Meaning to be determined by Microsoft.

INHERIT_ONLY

8

Meaning to be determined by Microsoft.

Returns

(number)  Returns 0 if successful. If this action fails, a non-zero error code will be returned defined in the Microsoft's WinError.h header file. For more information on the possible error codes please see: http://msdn.microsoft.com/en-us/library/ms819772.aspx.

See also:  Related Actions