FN-GM Posted April 18, 2012 Posted April 18, 2012 Hi, I use this script to apply permissions on home areas. I have used it a few times with no issues. I have come to use it again but it doesnt seem to apply the settings to folders that are all in capitals. Out home areas are setup like this Username > Documents The actual files are in the documents folder. Does anyone know why it does this please? Or does someone have an alternative? The file server is running 2008 R2. Thanks for /D %%i in (*) do ( cacls %%i\Documents /T /E /G Domain\%%i:c )
Steve21 Posted April 18, 2012 Posted April 18, 2012 (edited) Where are you trying to set the permissions? Only on the top folder? or everywhere etc? And what permissions is it you're setting? Certain ones can't be done through calcs Steve Edited April 18, 2012 by Steve21
FN-GM Posted April 18, 2012 Author Posted April 18, 2012 Its in a sub folder called documents. The parent folder is the same as the username. The rights are just read and write rights Its worked just fine apart from folders that are all in capitals.
mac_shinobi Posted April 18, 2012 Posted April 18, 2012 (edited) Its in a sub folder called documents. The parent folder is the same as the username. The rights are just read and write rights Its worked just fine apart from folders that are all in capitals. Would NTFS Fix by wisesoft do the trick ? http://www.wisesoft.co.uk/software/ntfsfix/default.aspx Edited April 18, 2012 by mac_shinobi
FN-GM Posted April 18, 2012 Author Posted April 18, 2012 That will give access to the parent folder not just the sub folder so it wont work i am afraid.
Davit2005 Posted April 19, 2012 Posted April 19, 2012 I use the following script which also creates a log file. User areas are on a 2003 server but I managed to use this with home areas on a 2008 R2 box at last place by changing set the folder to the network share and running the command on another 2003 server. @echo off setlocal set folder=h:\[ROOTFOLDER WHERE HOME AREAS ARE STORED]\ set log=errorlog.txt for /F "tokens=*" %%G in ('dir "%folder%" /A:D /B') do ( echo Y|cacls "%folder%\%%G" /T /C /G "%%G":F administrators:F > NUL 2>>"%log%" subinacl /errorlog="%log%" /file "%folder%\%%G" /setowner="%%G" > NUL 2>&1 subinacl /errorlog="%log%" /subdirectories "%folder%\%%G\*" /setowner="%%G" > NUL 2>&1 )
SkreeM1980 Posted April 23, 2012 Posted April 23, 2012 I recently used the following script on one of our student homefolder shares for /D %%i in (*) do ( subinacl /file %%i /grant=MOULTONAD\%%i=C "/grant=MOULTONAD\domain admins=f" /setowner=MOULTONAD\%%i subinacl /subdirectories %%i\* /grant=MOULTONAD\%%i=f "/grant=MOULTONAD\domain admins=f" /setowner=MOULTONAD\%%i ) It resets the permissions and the owner, the only thing to look at is the permissions being inherited from the parent afterwards. I re-jigged tehm to allow traverse to Folder only and all is good.
mickeyh080 Posted February 25, 2014 Posted February 25, 2014 Thanks for the code, it looks like exactly what I need but when I run it on a server 2003 box I get the following response. Any help would be most welcome. © Copyright 1985-2003 Microsoft Corp. C:\WINDOWS\system32>@echo off setlocal set folder=D:\Users\Students\Documents\Controlled_Assessment\ARCHIVE\ set log=errorlog.txt for /F "tokens=*" %%G in ('dir "%folder%" /A:D /B') do ( %%G was unexpected at this time. echo Y|cacls "%folder%\%%G" /T /C /G "%%G":F administrators:F > NUL 2>>"%log%" subinacl /errorlog="%log%" /file "%folder%\%%G" /setowner="%%G" > NUL 2>&1 Elapsed Time: 00 00:00:00 Done: 0, Modified 0, Failed 0, Syntax errors 1 Last Syntax Error:WARNING : /setowner=%%g : Error when checking arguments - D:\U sers\Students\Documents\Controlled_Assessment\ARCHIVE\%%G subinacl /errorlog="%log%" /subdirectories "%folder%\%%G\*" /setowner="%%G" > NU L 2>&1 Elapsed Time: 00 00:00:00 Done: 0, Modified 0, Failed 0, Syntax errors 1 Last Syntax Error:WARNING : /setowner=%%g : Error when checking arguments - D:\U sers\Students\Documents\Controlled_Assessment\ARCHIVE\%%G\* )
jklight Posted February 25, 2014 Posted February 25, 2014 (edited) Please use icacls instead of the older and problematic cacls Icacls: The New and Improved Cacls? | Security content from Windows IT Pro also, see this thread http://www.edugeek.net/forums/scripts/131364-icacls.html Edited February 25, 2014 by jklight
mickeyh080 Posted February 25, 2014 Posted February 25, 2014 Please use icacls instead of the older and problematic cacls Icacls: The New and Improved Cacls? | Security content from Windows IT Pro also, see this thread http://www.edugeek.net/forums/scripts/131364-icacls.html Did wonder where the calc entry came into it, does that mean I can just amend the original script and use icalc as below or will I need to search a different solution. @echo off setlocal set folder=h:\[ROOTFOLDER WHERE HOME AREAS ARE STORED]\ set log=errorlog.txt for /F "tokens=*" %%G in ('dir "%folder%" /A:D /B') do ( echo Y|icacls "%folder%\%%G" /T /C /G "%%G":F administrators:F > NUL 2>>"%log%" subinacl /errorlog="%log%" /file "%folder%\%%G" /setowner="%%G" > NUL 2>&1 subinacl /errorlog="%log%" /subdirectories "%folder%\%%G\*" /setowner="%%G" > NUL 2>&1 )
jklight Posted February 25, 2014 Posted February 25, 2014 I would use the commands from the other thread i linked to. for /? to see lots of help and examples for the for command.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now