Scripts Thread, Advances Folder Permission script in Coding and Web Development; I’m going through all of our kids folders one by one and changing the permissions, I’ve been having problems with ...
9th June 2011, 11:14 AM #1
Advances Folder Permission script
I’m going through all of our kids folders one by one and changing the permissions, I’ve been having problems with something on the network changing the permissions on random student home folders to Everyone: delete and nothing else.
I’m going through them and setting the Advanced Security settings for the folder manually, there has to be an easy way to set them. I did think about using Cacls or Xcacls as i have done in the past but after looking at it, it’s not granular enough for what I need, the settings are far to broad.
Before I go and try and develop my own script or something to do it I thought I’d ask.
---- Things it should do ----
Start at the top folder (Year Folder) and look down every folder contained within.
Each Folder is a new Home folder of a new user
Needs to look at the folder name and use it later
Re-set the file permissions to inherit from above and remove the permissions currently set for the user
(I have already made the changes to permissions the files inherit from the primary folder, that was easy)
Set a new permission based on the folder name (this is where cacls/xcacls won’t work)
The permission needs to be Allow everything except, Change Permissions and Take Ownership
it should then propagate this down the home folder tree and move on to the next folder till it does not have any folders left.
Im not looking forward to doing it manually, i am thinking it will fix the problem im having.
Can anyone point me in the right direction? I don’t know how to get vbscript to access the advanced file permissions, that’s really what i need help with, I think I can get it to do everything else, propagation might be a problem though
Any help would be appreciated, thanks
Last edited by alunmjones; 9th June 2011 at 11:19 AM.
IDG Tech News
11th April 2012, 10:25 AM #2
- Rep Power
Does anyone have any scripts to do this? I am in desperate need for the same script.
11th April 2012, 11:20 AM #3
I have cobbled this together by ripping out parts of a script I have and altering bits. With some testing it should work.... I think :/ Copy and paste into notepad and save as a .vbs
' Map a temporary network drive to year folder (root)
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "Q:", "\\server\share\year"
' Dump the list of folder names into a CSV file for use later
' To do this open a command prompt and use DIR command
intshort = 100
strDump = "dir /b >c:\yearx.csv"
' Define a variable to use for the folder name
' Read the contents of newly created CSV into an array
Const ForReading = 1
Set objFSO = Nothing
set objTextFile = Nothing
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\yearx.csv", ForReading)
Do While objTextFile.AtEndOfStream <> True
strNextLine = objTextFile.Readline
arrUSERData = split(strNextLine, ",")
strFolderName = arrUSERData(0)
' Use xcacls to set NTFS permissions
' This opens a command prompt and feeds the xcacls and variable into the line
' First command removes the old setting, second one creates the new one
intshort = 100
Set objShell = CreateObject("WScript.Shell")
strPart1 = "xcacls q:\"
strPart2 = " /R "
strPart3 = " /T /E /C /G "
objShell.SendKeys strPart1 & strFolderName & strPart2 & strFolderName
objShell.SendKeys strPart1 & strFolderName & strPart3 & strFolderName
' Clear the variable for the next pass through
set strFolderName = Nothing
' Close text file
' Remove the temporary network drive
DriveLetter1 = "Q:"
objNetwork.RemoveNetworkDrive Driveletter1, "True", "True"
11th April 2012, 11:28 AM #4
I would avoid using sendkeys where possible, if your email client or something else pops up half way through running said script it could get you into trouble
Originally Posted by themightymrp
12th April 2012, 10:46 AM #5
13th April 2012, 12:31 PM #6
- Rep Power
By NetworkGeezer in forum Coding
Last Post: 2nd September 2011, 05:10 PM
By alunmjones in forum Mac
Last Post: 8th June 2011, 02:44 PM
By bondbill2k2 in forum Windows Server 2000/2003
Last Post: 27th May 2011, 02:27 PM
By Chuckster in forum Coding
Last Post: 8th October 2009, 02:29 PM
Last Post: 12th October 2006, 09:37 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)