Get the App
SLTechnology News&Howtos  ›  Servers  › 

[batch]-icacls for file permission modification

Shulou Source: shulou.com Published: 2022-06-02 15:24:25 11月16日 Update

I. Access to directories and files

icacls D:\

Second, remove and add user rights (if prompted to refuse, please execute cmd with administrator rights).

icacls D:\ /remove "a username"

Add authorization to Authenticated Users.

icacls D:\ /grant "Authenticated Users":(M)

icacls D:\ /grant "Authenticated Users":(OI)(CI)(IO)(M)

Notes:

1. The declaration of inheritance should be placed before specific permissions. For example:(OI)(CI)(IO)(M) is correct, but (M)(OI)(CI)(IO) indicates invalid parameters.

2. The permissions in the simple permission sequence can be placed in () or not. For example, granting modification permission to Yifan can be written as icacls /grant Yifan:M or

icacls /grant yifan:(M)。

If only specific permissions are granted to the specified user, the permissions must be placed in (). For example, if icacls /grant yifan:(AD) is granted the right to read directories, then icacls /grant yifan:AD will prompt invalid parameters.

IV. Setting of Integrity Level

Set integrity level for test directory

icacls test /setintegritylevel (OI)(NP)(IO)H

Note that the level cannot be placed in ().

Two examples of recent work using icacls to add permissions in batches

(1)

for /f "skip=1 eol=;tokens=1-2 delims=," %a in (c:\yuyonghu-wenjianlujing.csv) do icacls %a /grant %b: /T

where: a and b are in csv file, after executing this statement, the root folder has permissions, but the subfiles and subfolders have no inheritance permissions

(2)

for /f "skip=1 eol=;tokens=1-2 delims=," %a in (c:\yuyonghu-wenjianlujing.csv) do icacls %a /grant %b:(OI)(CI)F /T

This statement adds (OI)(CI) to (1), and subfiles and subfolders inherit permissions.

Tags: Permissions files folders users directories levels prompts parameters integrity statements two in use events examples foundations sequences considerations user names administrators work Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Microsoft Xiaomi macOS NVidia