+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
Scripts Thread, Script to Create My Documents Subject Folders in Coding and Web Development; Guys would just like to say kudos on a fantastic resource. I have one poser for you script kings out ...
  1. #1
    SwedishChef's Avatar
    Join Date
    Apr 2006
    Location
    Plymouth
    Posts
    115
    Thank Post
    15
    Thanked 11 Times in 8 Posts
    Rep Power
    19

    Script to Create My Documents Subject Folders

    Guys would just like to say kudos on a fantastic resource.

    I have one poser for you script kings out there, we would like to give our new/existing students a more easier life by pre-creating (if they dont exist already) subject folders per year.

    eg: A year 9 student will have three "root" folders under their redirected "my docs" ie: Year 7, year 8, year 9 and each of these will have the core subjects under each year. Next year they will gain a Year 10 folder

    There must be an easy script to do this at login time.

    Anyone done this before ? I have managed to get myself part of the code, (attacthed) but im stuck on knowing how to parse the Home Folder of the student and to choose the folder depending on what year they are in.

    our AD is structurered to re-direct My docs to a "My Documents" under the home directory and each students is a member of a group per ou based on the year they joined (but I cud start to Maintain a "Year x" group structure as well, or just change the script each year)

    here's living in hope!!

    Gary
    Attached Files Attached Files

  2. #2

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Script to Create My Documents Subject Folders

    This could be quite straigth forward.

    CD into the folder containing the student folders.
    Do directory enumeration and then a foreach to create the subject folders for each student.

  3. #3
    SwedishChef's Avatar
    Join Date
    Apr 2006
    Location
    Plymouth
    Posts
    115
    Thank Post
    15
    Thanked 11 Times in 8 Posts
    Rep Power
    19

    Re: Script to Create My Documents Subject Folders

    Sorry I should have explained more, I want to use this as part of a login script so to check/create them at first/subsequent logon.

    This way new users and users who have deleted them will still have the structure. (also this way the previous versions client instructions can make sense to my users)

  4. #4

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Script to Create My Documents Subject Folders

    That's even easier then.

    All you have to do is something like
    Code:
    IF NOT exist \\server\share\student_username\subject MD   \\server\share\student_username\subject

  5. #5

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Script to Create My Documents Subject Folders

    My preference would be too prefab the folders before login and set permisisons so that users can't delete folders.

    You'll have to test it but it could be a dreag on your logn time depending on how convoluted the folder tree is.

  6. #6
    SwedishChef's Avatar
    Join Date
    Apr 2006
    Location
    Plymouth
    Posts
    115
    Thank Post
    15
    Thanked 11 Times in 8 Posts
    Rep Power
    19

    Re: Script to Create My Documents Subject Folders

    not bothered at the moment if they delete them, however a vb solution would be preferable, I would rather that they created the folders for ownership reasons.

    It isnt possbile to do this before login , as we are using folder redirection , so the "My Documents" folder wont be created for a new users until first login.

    Also I'm not too sure of a neat way to do this per year group with a single script.

    Sorry if the goal posts are quite fixed.

  7. #7

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Script to Create My Documents Subject Folders

    OK let's go back to the beginning. Is your goal to create a sturcture like this?


    MyDocs share
    |
    |____Year7
    | |__English
    | |__Maths
    | |__Sci
    |
    |____Year8
    | |__English
    | |__Maths
    | |__Sci

  8. #8

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,600
    Thank Post
    109
    Thanked 769 Times in 598 Posts
    Rep Power
    181

    Re: Script to Create My Documents Subject Folders

    Do your usernames start with the year of entry or some other means of identifying their yeargroup? If so, inspecting the username will allow you to find out how many folders you need to create.

    You can then iterate through the list of folders within the level of My Documents and add the required folders.

  9. #9

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,804
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: Script to Create My Documents Subject Folders

    What about checking their group membership Ric? Wouldn't that work?

  10. #10

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,600
    Thank Post
    109
    Thanked 769 Times in 598 Posts
    Rep Power
    181

    Re: Script to Create My Documents Subject Folders

    Quote Originally Posted by Geoff
    What about checking their group membership Ric? Wouldn't that work?
    Smart arse! :P

  11. #11

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Script to Create My Documents Subject Folders

    Actually Ric_ you have a point as parsing the username is probably quicker than doing ADSI querie for group membership info.

  12. #12
    SwedishChef's Avatar
    Join Date
    Apr 2006
    Location
    Plymouth
    Posts
    115
    Thank Post
    15
    Thanked 11 Times in 8 Posts
    Rep Power
    19

    Re: Script to Create My Documents Subject Folders

    unfortuantly they dont, i was thing of some way of testing for membership of a AD group

  13. #13

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: Script to Create My Documents Subject Folders

    You can have a look at the user and group sample scripts on the Technet Script Center. They all seem to involve taking a group and enumerating the members and doing reptitive matching till you find the right user. For a school of 2000 students this may not be ideal.

    What you can do is try the NetworkGeezer's quick and dirty group determination algorithm.

    Create a folder for each year and then put a text file in folder. Now set the NTFS permissions so that only a member of particular year group can access the textfile. OK maybe the folder creation step may not be necessary just provide a token file which only group can access.

    All you have to do to find the group a student is in is to do an if file exists test until you can access one of the files. This will give you their year group.

    Code:
    IF EXIST ..\year7\Year7_token.txt Year_Group=YEAR7
    IF EXIST ..\year8\Year8_token.txt Year_Group=YEAR8
    ....
    ....
    IF EXIST ..\year11\Year11_token.txt Year_Group=YEAR11
    This would mean in the worst case it would take 5 attempts (or 7 if you have a 2 year sixthform) to find the year group.

  14. #14
    sahmeepee's Avatar
    Join Date
    Oct 2005
    Location
    Greater Manchester
    Posts
    795
    Thank Post
    20
    Thanked 70 Times in 42 Posts
    Rep Power
    34

    Re: Script to Create My Documents Subject Folders

    Can't you pass the year into the login script as a parameter:

    Open up ADUC and find all your year 7 (say) users. I think you've said that you have an OU for each year, so that should be easy.

    Select all the year 7 users > properties > profile tab

    Set the login script to e.g. "loginscript.bat year7"

    In the login script the parameter will be available as %1 so you can do some IF statements to get the desired result. If you pass in "7" instead of "year7" you could even use the greater than/less than comparisons in the IF statement.

    NB I've never tried this 'cos we use KiXtart for login scripts and it has all this stuff built in. Go KiX!

  15. #15
    SwedishChef's Avatar
    Join Date
    Apr 2006
    Location
    Plymouth
    Posts
    115
    Thank Post
    15
    Thanked 11 Times in 8 Posts
    Rep Power
    19

    Re: Script to Create My Documents Subject Folders

    I've cracked it nown a vb solution which is what I wanted. I use the parameter part of the AD policy to pass the year group.


    When im back in tomorrow ill post my finished script.

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Script to create a VPN connection
    By Norphy in forum Scripts
    Replies: 5
    Last Post: 20th April 2010, 11:37 AM
  2. Replies: 21
    Last Post: 29th December 2007, 10:53 PM
  3. VB Script to create folders
    By markesmith in forum Scripts
    Replies: 2
    Last Post: 26th April 2007, 03:03 PM
  4. Replies: 0
    Last Post: 17th February 2007, 04:43 PM
  5. Script to create a local user on a XP box.
    By tosca925 in forum Scripts
    Replies: 3
    Last Post: 12th October 2005, 12:04 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •