4

I need to write a small Windows software (using VisualBasic PL) to create automatically folder trees, following a fixed structure; in particular, I have to create the main folder with several subfolders, each one with different permissions from the others (I already know which permission I may assign, for each subfolder, to each users group; all contained in the same domain).

In order to replicate the existing permission structure (not created by me, so cannot be modified), I have to edit the following section of the Security tab of Folder Properties:

Permissions into security tab

After several researches, I found that the command I should use is icacls (since I'm in a domain network, I will probably have to use Powershell instead of CMD, could you please explain me about this?) and so I've tried to use this command in order to assign permissions (the following tryout concerns in giving full access to the guest user for a certain folder):

icacls "C:\Users\Administrator\Desktop\prova\Folder" /grant DELL-XPS\prova:F

At the beginning, I thought the command wasn't properly working but I suddently realised that the edited permissions were the ones in the Advanced section, reachable from the button in the previous picture.

How can I edit, through command line (CMD or PowerShell) the permissions in the red section of the picture?

2
  • Look at the ATTRIB command . attrib /? to see what it does.
    – anon
    Commented Jun 18, 2023 at 15:15
  • @John thanks for your answer. I'm trying to understand the attributes allowed by the ATTRIB command: where can I set the users/group of users to assign the permissions? It also seems that the the permission shown in the Security tab of Folder Properties (FullControl, Modify, Read&Execute, ListFolderContents, Read, Write) are not directly assignable (probably I have to combine more attributes for ATTRIB to obtain the permission as shown in the Security Tab). Thanks a lot!
    – Nicola
    Commented Jun 18, 2023 at 15:33

1 Answer 1

7

To grant John full control over the D:\test folder and sub-folders:

icacls "D:\test" /grant John:(OI)(CI)F /T

Explanation:

  • F = Full Control
  • CI = Container Inherit, subordinate containers/folders will inherit
  • OI = Object Inherit, subordinate files will inherit
  • /T = Apply recursively to existing files and sub-folders, as OI and CI only apply to new files and sub-folders.

For complete documentation, you may run "icacls" with no arguments or see the documentation for Icacls.

Source : How to grant permission to users for a directory using command line in Windows?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .