Script to alter security on same folder in multiple folders
I need a script (pref VB) to change permissions on a folder in multiple folders.
Example, imagine users home directory, so a folder contains all the users. Each user has a folder insiide their home driectory called 'examples'. I need a script to search for that folder inside each users home directory and change the permissios to 'read, list folder contents'
Can this be done?
This is not being done on users home directories but this was the best example i could give.
Or imagine their are 10 folders named 1 to 10. inside each folder are 5 folders named A,B,C,D and E. I want a script to search for the folder named 'D' and change the permission on that folder only.
Re: Script to alter security on same folder in multiple folders
Well the there's a vbs version of xcacls which will let you modify NTFS permissions. I use it to modify local directory permissions on workstations at machine start up.
As for it looking for all folders named 'D' in a directory tree, It can't do that itself, but it's a start.
Cobbled together this bit of code which examines the directory tree under the specified directory, it then compares the all the folder and subfolder names to the specified folder name. If it finds a match it then calls the XCACLS.VBS script using the full folder path and the specified options. I've not tested this, so it may need some tweaking. I know the directory search bit works, just the line that calls XCACLS might need some adjusting.
Hope that helps,
Set objShell = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
For Each Subfolder in Folder.SubFolders
if Subfolder.Name = "FOLDERNAME" then
runline = "c:\xcacls.vbs " & subfolder.Path & " /E /G etc. etc."