ceebster Posted March 29, 2010 Posted March 29, 2010 Hi All Heres a tricky one for you. We have some student record folders setup within a share. Folder names are the students names. Our admin manager wants to put a new folder in each of these student folders and apply permissions to each folder for a particular group of users. I assume its going to be a script. Can this be done? Thanks in advance Chris
srochford Posted March 29, 2010 Posted March 29, 2010 Can this be done? Yes :-) If you give us a bit more of a clue about what you're trying to do then it may be easier :-) but as a start, let's assume that you have a top level folder called "students" and in that you've got "student1", "student2" etc and you want to put "new_folder" in each of these and give that folder the same access as the parent folder but also give write access to the group called "special_users" Let's also assume you can map to that top level folder as \\server1\students You can do this as a batch file: net use z: \\server1\students z: for /d %%i in (*) do md %%i\new_folder for /d %%i in (*) do cacls %%i\new_folder /e /g special_users:c - first 2 lines I hope are easy. Next line steps through each directory in turn and creates "new_folder" under it. Final line steps through the directories again and this time edits the permissions to add the special_users group
SteveLaw Posted March 29, 2010 Posted March 29, 2010 It can yes be done with a script, absolutely, but I haven't got one I can give you (and wouldn't want to just throw one together without testing). I'm sure someone has something similar somewhere. EDIT: There you go, as I was writing
danrhodes Posted March 29, 2010 Posted March 29, 2010 I would use a logon script something like... @echo off if exist "U:\ICT" goto end MKDIR U:\ICT CACLS U:\ICT /E /T /C /G "GroupName":F :end Exit So if a folder named ICT Exists in U: then the script terminates, if the folder does not exist then it will create the folder and set the permissions using cacls. D
ceebster Posted March 29, 2010 Author Posted March 29, 2010 (edited) Hi srochford Thanks! Sorry should of been more clear Folder stucture q:\common\STUDENT RECORDS\A-D\surname, firstname would like a folder called ECM creating in these folders - and assign a group for the RWX permmission The main student folders area created - need new folders created within this - could be tricky as would have to tell the script the name of the orginal folder and get it to go into each of these Chris Edited March 29, 2010 by ceebster
TechSupp Posted March 29, 2010 Posted March 29, 2010 Glad someone asked this, was wanting a similar thing. Not wanting to hijack the thread but could I aslo at the same time copy all the files except any existing folders in to the newly created folder (i.e. making a backup of their years work)?
danrhodes Posted March 29, 2010 Posted March 29, 2010 (edited) Hi srochford Thanks! Sorry should of been more clear Folder stucture q:\common\STUDENT RECORDS\A-D\surname, firstname would like a folder called ECM creating in these folders - and assign a group for the RWX permmission Chris Do you map these folders to a Drive letter that would be easier to script if you do! are they the students home documents folders? D Edited March 29, 2010 by danrhodes
danrhodes Posted March 29, 2010 Posted March 29, 2010 Glad someone asked this, was wanting a similar thing. Not wanting to hijack the thread but could I aslo at the same time copy all the files except any existing folders in to the newly created folder (i.e. making a backup of their years work)? Sorry, is that not what tape or NAS backup is for, seems a bit pointless to me does this!
ceebster Posted March 29, 2010 Author Posted March 29, 2010 [quote=danrhodes;488022 This assumes though that the folder names are same as the username, otherwise you will ahve to use excel and conctenate to create a "mail merge" batch script using the exported fodler names! D Unfortuanlty the Admin staff have used the Students full names q:\common\q:\common\STUDENT RECORDS\A-D\Abbots, Joe q:\common\q:\common\STUDENT RECORDS\A-D\Adkins, Joe q:\common\q:\common\STUDENT RECORDS\A-D\Andrews, Joe I can get the exported usernames not sure about the last bit you said Cheers
danrhodes Posted March 29, 2010 Posted March 29, 2010 What are the folders used for, to store students work when they log on, are they there My Documents folders? Or do they just hold info about the students that Admin staff will be using? D
ceebster Posted March 29, 2010 Author Posted March 29, 2010 Do you map these folders to a Drive letter that would be easier to script if you do! are they the students home documents folders? D These student record folders are mapped to a drive Q:\ no they are not the students home documents folders Cheers Chris
danrhodes Posted March 29, 2010 Posted March 29, 2010 Ah right, if they aren't the home folders then it may be a slight more difficult. One way to do it would be to use Excel and concatenate and using the exported folder names using dir! See attached xls file.Concatenate.xls
ceebster Posted March 29, 2010 Author Posted March 29, 2010 i can get that info - how do i add it into the script Sorry Scripting not my fortey! C
danrhodes Posted March 29, 2010 Posted March 29, 2010 just put it into the excel sheet attached the script you need will be at the far right, copy and paste that into notepad and you have your script. DNew_Concatenate_Example.xls 1
TechSupp Posted March 29, 2010 Posted March 29, 2010 Sorry, is that not what tape or NAS backup is for, seems a bit pointless to me does this! No not pointless at all as yes we back up student folders with all their work but the co-ordinator just wants each pupils folders to be a little more organised so that they can see easily what work is completed in each year and the folder is not full of hundreds of files, just a few folders and the current years work.
SteveLaw Posted March 29, 2010 Posted March 29, 2010 Is this a one off task? Can't you use something like this (vbs): Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder("q:\common\q:\common\STUDENT RECORDS\A-D\") Set colSubfolders = objFolder.Subfolders For Each objSubfolder in colSubfolders ' Do the thing Next
ceebster Posted March 29, 2010 Author Posted March 29, 2010 just put it into the excel sheet attached the script you need will be at the far right, copy and paste that into notepad and you have your script. D How do i set permissions then for a partucluar group and no one else? I think the folders get permissions fromt he top Chris
danrhodes Posted March 29, 2010 Posted March 29, 2010 How do i set permissions then for a partucluar group and no one else? I think the folders get permissions fromt he top Chris Use CACLS to set permissions from a script. CACLS q:\common\q:\common\STUDENT RECORDS\A-D\Foldername /E /T /C /G "GroupName":F Quick and easy. VBS is always good too Steve :-) although can be confusing for people at Chris's current level of scripting. Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder("q:\common\q:\common\STUDENT RECORDS\A-D\") Set colSubfolders = objFolder.Subfolders For Each objSubfolder in colSubfolders ' Do the thing Next D
apeo Posted March 29, 2010 Posted March 29, 2010 I think the script will look something like this: Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder("q:\common\STUDENT RECORDS\A-D\") Set colSubfolders = objFolder.Subfolders Set WshShell = CreateObject("wscript.shell") For Each objSubfolder In colSubfolders Set objNewFolder = objFSO.CreateFolder(objSubfolder.path & "\ECM") WshShell.run "xcacls " & chr(34) & objNewfolder.path & chr(34) & "/T /C /P " & chr(34) & "domain\security group" & chr(34) & ":F /y" Set objNewFolder = Nothing Next You should test it on a temporary folder first and you will need to ensure that xcacls is available/installed i.e. in system32.
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