+ Post New Thread
Results 1 to 6 of 6
Scripts Thread, Wanted - script to change ownership on a set of folders in Coding and Web Development; I need to change the ownership on a large amount of folders back to the administrator so that I can ...
  1. #1
    Andi's Avatar
    Join Date
    Feb 2007
    Location
    Newport, South Wales
    Posts
    276
    Thank Post
    52
    Thanked 4 Times in 4 Posts
    Rep Power
    16

    Wanted - script to change ownership on a set of folders

    I need to change the ownership on a large amount of folders back to the administrator so that I can delete them. They are old redirected appdata folders.

    However I need the option of excluding the folder 'staff' which is sitting amongst these folders.

    Is there anything I can do with cacls or similar to achieve this? Doing it by hand will take hours.

  2. #2
    Friez's Avatar
    Join Date
    Dec 2006
    Posts
    839
    Thank Post
    22
    Thanked 22 Times in 21 Posts
    Rep Power
    23
    XCacls.vbs How to use Xcacls.vbs to modify NTFS permissions

    You'll want to use the D permission. e.g.

    Code:
    xcacls \\someserver\somepath /g "Domain\Domain Admins":D
    Run from a batch file or another VBS:

    Code:
    Set objShell = CreateObject("Wscript.Shell") 
    Call objShell.Run("%COMSPEC% /c echo y | xcacls \\someserver\somepath /g ""Domain\Domain Admins"":D, 7, False)

  3. Thanks to Friez from:

    Andi (30th October 2008)

  4. #3
    Andi's Avatar
    Join Date
    Feb 2007
    Location
    Newport, South Wales
    Posts
    276
    Thank Post
    52
    Thanked 4 Times in 4 Posts
    Rep Power
    16
    Thanks, but won't that still apply the change in ownership to the staff folder? I need the script to ignore that folder all together.

  5. #4
    jmcdermott's Avatar
    Join Date
    Feb 2008
    Location
    Cornwall
    Posts
    173
    Thank Post
    16
    Thanked 43 Times in 35 Posts
    Rep Power
    21
    Ok assuming you want to do this on windows from the cacls ref, you could try the following:

    you want to achive changing all security settins apart from any folder called staff.

    1) Use window search function to find all folders called staff.
    2) Select all staff folders and bring up the properties.
    3) Go to the security tab, click advaced
    4) untick Inherit from parent folder, click ok, close search box
    5) Now any security you set higher up the tree will not filter to these sub folders.
    6) On the folders at the top of the tree set the security settings you want to apply.

    Hope this helps.

  6. Thanks to jmcdermott from:

    Andi (30th October 2008)

  7. #5
    Andi's Avatar
    Join Date
    Feb 2007
    Location
    Newport, South Wales
    Posts
    276
    Thank Post
    52
    Thanked 4 Times in 4 Posts
    Rep Power
    16
    You may actually be a genius!

    So simple I hadn't thought of it. Now I just hope it works

  8. #6
    Friez's Avatar
    Join Date
    Dec 2006
    Posts
    839
    Thank Post
    22
    Thanked 22 Times in 21 Posts
    Rep Power
    23
    If you do go the scripty route, just call the above many times for each folder you want to change (except the one you don't). There's various ways of getting folder names out nice and quick (if they're all conveniently on the same computer in the same master folder a dir /b /ad > c:\folders.txt will do you nicely.

    Or you could use the method as mentioned above, depends what you need really :P

  9. Thanks to Friez from:

    Andi (30th October 2008)

SHARE:
+ Post New Thread

Similar Threads

  1. VB script to delete certain folders
    By PTD in forum Scripts
    Replies: 7
    Last Post: 4th June 2008, 12:30 PM
  2. Script to delete certain folders
    By Pumaedition in forum Scripts
    Replies: 4
    Last Post: 22nd April 2008, 10:08 PM
  3. Wanted: VBScript to delete folders from C:
    By timbo343 in forum Scripts
    Replies: 7
    Last Post: 7th February 2008, 11:50 AM
  4. script to change permission on folders for new domain
    By scottyses in forum Wireless Networks
    Replies: 1
    Last Post: 14th January 2008, 08:41 PM
  5. VB Script to create folders
    By markesmith in forum Scripts
    Replies: 2
    Last Post: 26th April 2007, 03:03 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
  •