thanks to answers available here – I know how to replicate permission of an identical folder using icacls /save & /restore or robocopy /MIR. But, i can't make them to bring the same user permission from a folder to target folder with different content. With ìcacls /restore, the target folder still get the user permission inherit from it's parent (although i already explicitly disable inheritance).
My use case is, I have a portable app folder and it will run brokenly when i put it in this troubled subfolder, but fully working when i put it in the root of the same D:\ drive. My folder path doesn't have any "forbidden"characters like % ^ etc., only letters and also the path is not super long.
Is there a way to quickly replicates permission from a known good location to a target folder? Please help.
Many thanks.
11 Answer
EDIT:
Sorry for posting in a rush.
After checking again, here everything what I found:
- the
robocopycommand doesn't assign the permission to file(s) or subfolder(s) inside. 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 /savethenIcacls /restoreactually also work. But it applies the folder inheritance state. If the "source" having inheritance enabled, then the target folder also get the inheritance enabled (from it's parent, not from source's parent). So, the "source" need to get folder inheritance disabled temporarily.
*) I think it is better not to do this to anticipate breaking the source if something get wrong or forget to revert all changes on "source".
- I'm not testing further with powershell
get-acl -path | set-acl -pathbut previously I found it worked likeicacls /restore
For my use case, I choose the robocopy command. Epecially after finding this . I'm not testing this, only imagined this can be combined together into one-line cmd command like:
robocopy d:\source_folder_permission destination_folder_permission /e /sec /secfix /xc /xn /xo /xx /xl & icacls "destination_folder_permission\*" /q /c /t /reset
That is all. Cheers :)
Finally! I found the dream answer. Thanks to this guy Coping permissions only using Robocopy
This is the example robocopy command:
robocopy d:\source_folder_permission destination_folder_permission /e /sec /secfix /xc /xn /xo /xx /xl
I run it as Administrator.
Hope this valuable for everyone. Good day!