+ Post New Thread
Results 1 to 12 of 12
Scripts Thread, Script to reset home area permissions in Coding and Web Development; Hi, I use this script to apply permissions on home areas. I have used it a few times with no ...
  1. #1

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,961
    Thank Post
    886
    Thanked 1,710 Times in 1,478 Posts
    Blog Entries
    12
    Rep Power
    449

    Script to reset home area permissions

    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

    Code:
    for /D %%i in (*) do (
       cacls %%i\Documents /T /E /G Domain\%%i:c
    )

  2. #2

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,696
    Thank Post
    335
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    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
    Last edited by Steve21; 18th April 2012 at 04:23 PM.

  3. #3

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,961
    Thank Post
    886
    Thanked 1,710 Times in 1,478 Posts
    Blog Entries
    12
    Rep Power
    449
    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.

  4. #4

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,765
    Thank Post
    3,274
    Thanked 1,053 Times in 974 Posts
    Rep Power
    365
    Quote Originally Posted by FN-GM View Post
    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
    Last edited by mac_shinobi; 18th April 2012 at 04:59 PM.

  5. #5

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,961
    Thank Post
    886
    Thanked 1,710 Times in 1,478 Posts
    Blog Entries
    12
    Rep Power
    449
    That will give access to the parent folder not just the sub folder so it wont work i am afraid.

  6. #6

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,961
    Thank Post
    886
    Thanked 1,710 Times in 1,478 Posts
    Blog Entries
    12
    Rep Power
    449
    Bump

  7. #7

    Join Date
    May 2011
    Location
    Jus North of London, close but not too close
    Posts
    778
    Thank Post
    175
    Thanked 57 Times in 55 Posts
    Rep Power
    35
    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
    )

  8. #8

    Join Date
    Jan 2009
    Location
    Northants
    Posts
    138
    Thank Post
    3
    Thanked 11 Times in 10 Posts
    Rep Power
    13
    I recently used the following script on one of our student homefolder shares

    Code:
    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.

  9. #9

    Join Date
    May 2008
    Location
    Norfolk
    Posts
    114
    Thank Post
    16
    Thanked 2 Times in 1 Post
    Rep Power
    13
    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.

    (C) Copyright 1985-2003 Microsoft Corp.

    C:\WINDOWS\system32>@echo off
    setlocal

    set folder=D:\Users\Students\Documents\Controlled_Asse ssment\ARCHIVE\
    set log=errorlog.txt

    for /F "tokens=*" %%G in ('dir "%folder%" /A /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\ARCH IVE\%%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\ARCH IVE\%%G\*
    )

  10. #10

    Join Date
    Jul 2012
    Location
    Boerne Texas USA
    Posts
    45
    Thank Post
    0
    Thanked 9 Times in 9 Posts
    Rep Power
    6
    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 iCacls
    Last edited by jklight; 25th February 2014 at 03:37 PM.

  11. #11

    Join Date
    May 2008
    Location
    Norfolk
    Posts
    114
    Thank Post
    16
    Thanked 2 Times in 1 Post
    Rep Power
    13
    Quote Originally Posted by jklight View Post
    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 iCacls
    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 /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
    )

  12. #12

    Join Date
    Jul 2012
    Location
    Boerne Texas USA
    Posts
    45
    Thank Post
    0
    Thanked 9 Times in 9 Posts
    Rep Power
    6
    I would use the commands from the other thread i linked to.

    for /?
    to see lots of help and examples for the for command.

SHARE:
+ Post New Thread

Similar Threads

  1. Home Area Permissions
    By DSapseid in forum Scripts
    Replies: 15
    Last Post: 21st May 2012, 01:27 PM
  2. Studywiz point elocker to user home area
    By Zorba in forum Web Development
    Replies: 7
    Last Post: 6th October 2009, 02:27 PM
  3. terminal script to create home dirs in OS X
    By HodgeHi in forum Coding
    Replies: 6
    Last Post: 3rd July 2009, 10:13 AM
  4. Reset Home folder permissions
    By garym2000 in forum Windows
    Replies: 10
    Last Post: 29th March 2008, 11:16 AM
  5. Replies: 0
    Last Post: 20th August 2007, 02:20 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •