Jump to content

Recommended Posts

Posted

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
)

Posted (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 by Steve21
Posted

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.

Posted

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

)

Posted

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.

  • 1 year later...
Posted

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\*

)

Posted

 

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

)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...