0

This is in a Windows environment. I have an issue on a NAS volume where the Administrator has lost all access to various folders and files. I can find the offending folders and files and have been using batch files to grant ownership to the administrator account and then granting the access, but have a problem with nested folders. So if we have -

"h:\folder1\folder2\folder3\folder4" where EACH folder is not accessible or owned by Administrator

I list the folders into a txt file and then edit to run the commands to grant ownership in a batch file thus -

fileacl h:\folder1 /O Administrator:F
fileacl h:\folder1\folder2 /O Administrator:F
fileacl h:\folder1\folder2\folder3 /O Administrator:F
fileacl h:\folder1\folder2\folder3\folder4 /O Administrator:F

then I edit to create the following to grant access -
fileacl h:\folder1 /G Administrator:F
fileacl h:\folder1\folder2 /G Administrator:F
fileacl h:\folder1\folder2\folder3 /G Administrator:F
fileacl h:\folder1\folder2\folder3\folder4 /G Administrator:F

The problem is that only folder1 will be fixed as I won't have access UNTIL the second command is completed to touch folder2. Same for 3 & 4.

My question is - is it possible to execute two commands per line of the created text file listing so that it would execute both commands for folder1 before moving on to folder 2 and so on? Manually copying a& organizing this all would take forever as I have several thousand nested folders. A FOR loop in DOS/CMD prompt?
Thx!

0

Do you mean the concatenation of two commands using the && operator? Eq. fileacl h:\folder1 /O Administrator:F && fileacl h:\folder1 /G Administrator:F

  • Only if the two commands can pipe in a text file listing the folders and do both commands on a line before traversing down the list. – user275373 Nov 19 '13 at 22:11
0

Try using

icacls h:\ /grant Administrator:(CI)(OI)F

The above should grant Administrator Full Access to every file and folder under H:\ and all subdirectories. AND it will also set "Object Inherit" and "Container Inherit" so the permission should traverse to all folders below it.

Prior to doing it, run it without the /t (traverse to all subdirs) and maybe just for a specific folder.

eg.

icacls h:\folder1 /grant Administrator:F

This should give Administrator Full Access to 'folder1' only but does not allow the permission to be inherited to folders below them.

Hope this helps

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.