Andi Posted October 30, 2008 Posted October 30, 2008 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.
Friez Posted October 30, 2008 Posted October 30, 2008 XCacls.vbs How to use Xcacls.vbs to modify NTFS permissions You'll want to use the D permission. e.g. xcacls \\someserver\somepath /g "Domain\Domain Admins":D Run from a batch file or another VBS: Set objShell = CreateObject("Wscript.Shell") Call objShell.Run("%COMSPEC% /c echo y | xcacls \\someserver\somepath /g ""Domain\Domain Admins"":D, 7, False) 1
Andi Posted October 30, 2008 Author Posted October 30, 2008 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.
jmcdermott Posted October 30, 2008 Posted October 30, 2008 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. 1
Andi Posted October 30, 2008 Author Posted October 30, 2008 You may actually be a genius! So simple I hadn't thought of it. Now I just hope it works
Friez Posted October 30, 2008 Posted October 30, 2008 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 1
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