Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy permissions from one Windows Folder to another

I need to create a small C# Windows app which copies security permissions from one folder to another. That includes copying group permissions too. What would be the best way to approach such a challenge?

Yosief Kesete

like image 273
Yosief Kesete Avatar asked Dec 01 '10 10:12

Yosief Kesete


People also ask

How do I copy permissions from one folder to another in Windows?

So, it need this additional step (on Windows 10): Folder properties > Security tab > Advanced > Permission = Check the box at "Replace all child object permission entries with inheritable permission entries from this object" Icacls /save then Icacls /restore actually also work.

How do I copy an ACL from one directory to another?

We will copy the permission from one folder to another using Get-ACL of the source and Set-ACL to the destination path using the pipeline. Once the above operation is done, you can check the permission on the destination path. You can see the delta user permission is added and other permissions are also copied.

How do I copy permission from one file to another?

To copy file permissions from one file to another file, use chmod command with the --reference switch in the following syntax, where reference_file is the file from which permissions will be copied rather than specifying mode (i.e octal or numerical mode permissions) for file.


1 Answers

Rather than writing the whole thing yourself, why don't you get your app to run a tool like AccessChk (use the -l parameter), and then apply permissions to the target folder based on the info you parse from the output of AccessChk.

like image 140
slugster Avatar answered Sep 21 '22 14:09

slugster