text
stringlengths
0
4.23k
<directory>
<ACLfile>
<directory>
Remarks
SIDs may be in either numerical or friendly name form. If you use a numerical form, affix the wildcard character * to the beginning of the SID.
This command preserves the canonical order of ACE entries as:
Explicit denials
Explicit grants
Inherited denials
Inherited grants
The <perm> option is a permission mask that can be specified in one of the following forms:
<perm>
A sequence of simple rights (basic permissions):
F - Full access
M- Modify access
RX - Read and execute access
R - Read-only access
W - Write-only access
A comma-separated list in parenthesis of specific rights (advanced permissions):
D - Delete
RC - Read control (read permissions)
WDAC - Write DAC (change permissions)
WO - Write owner (take ownership)
S - Synchronize
AS - Access system security
MA - Maximum allowed
GR - Generic read
GW - Generic write
GE - Generic execute
GA - Generic all
RD - Read data/list directory
WD - Write data/add file
AD - Append data/add subdirectory
REA - Read extended attributes
WEA - Write extended attributes
X - Execute/traverse
DC - Delete child
RA - Read attributes
WA - Write attributes
Inheritance rights may precede either <perm> form:
<perm>
(I) - Inherit. ACE inherited from the parent container.
(OI) - Object inherit. Objects in this container will inherit this ACE. Applies only to directories.
(CI) - Container inherit. Containers in this parent container will inherit this ACE. Applies only to directories.
(IO) - Inherit only. ACE inherited from the parent container, but does not apply to the object itself. Applies only to directories.
(NP) - Do not propagate inherit. ACE inherited by containers and objects from the parent container, but does not propagate to nested containers. Applies only to directories.
Examples
To save the DACLs for all files in the C:\Windows directory and its subdirectories to the ACLFile file, type:
icacls c:\windows\* /save aclfile /t
To restore the DACLs for every file within ACLFile that exists in the C:\Windows directory and its subdirectories, type:
icacls c:\windows\ /restore aclfile
To grant the user User1 Delete and Write DAC permissions to a file named Test1, type:
icacls test1 /grant User1:(d,wdac)
To grant the user defined by SID S-1-1-0 Delete and Write DAC permissions to a file, named Test2, type:
icacls test2 /grant *S-1-1-0:(d,wdac)
if
Performs conditional processing in batch programs.
Syntax
if [not] ERRORLEVEL <number> <command> [else <expression>]
if [not] <string1>==<string2> <command> [else <expression>]
if [not] exist <filename> <command> [else <expression>]
If command extensions are enabled, use the following syntax:
if [/i] <string1> <compareop> <string2> <command> [else <expression>]
if cmdextversion <number> <command> [else <expression>]
if defined <variable> <command> [else <expression>]
Parameters
Parameter
Description
not
Specifies that the command should be carried out only if the condition is false.
errorlevel <number>
Specifies a true condition only if the previous program run by Cmd.exe returned an exit code equal to or greater than number.
<command>
Specifies the command that should be carried out if the preceding condition is met.
<string1>==<string2>
Specifies a true condition only if string1 and string2 are the same. These values can be literal strings or batch variables (for example, %1). You do not need to enclose literal strings in quotation marks.
exist <filename>
Specifies a true condition if the specified file name exists.