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 ...
30th October 2008, 02:46 PM #1
- Rep Power
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.
30th October 2008, 02:55 PM #2
XCacls.vbs How to use Xcacls.vbs to modify NTFS permissions
You'll want to use the D permission. e.g.
Run from a batch file or another VBS:
xcacls \\someserver\somepath /g "Domain\Domain Admins":D
Set objShell = CreateObject("Wscript.Shell")
Call objShell.Run("%COMSPEC% /c echo y | xcacls \\someserver\somepath /g ""Domain\Domain Admins"":D, 7, False)
30th October 2008, 02:58 PM #3
- Rep Power
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.
30th October 2008, 03:01 PM #4
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.
Thanks to jmcdermott from:
30th October 2008, 03:04 PM #5
30th October 2008, 03:46 PM #6
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
Last Post: 4th June 2008, 12:30 PM
By Pumaedition in forum Scripts
Last Post: 22nd April 2008, 10:08 PM
By timbo343 in forum Scripts
Last Post: 7th February 2008, 11:50 AM
By scottyses in forum Wireless Networks
Last Post: 14th January 2008, 08:41 PM
By markesmith in forum Scripts
Last Post: 26th April 2007, 03:03 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)