+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
Scripts Thread, Script to copy files to student home directory. in Coding and Web Development; Has anyone written a script that has the following: 1. Ability to browse or change in code, the location of ...
  1. #1

    Join Date
    Sep 2005
    Posts
    143
    Thank Post
    0
    Thanked 3 Times in 3 Posts
    Rep Power
    19

    Script to copy files to student home directory.

    Has anyone written a script that has the following:
    1. Ability to browse or change in code, the location of some files, eg d:\files-to-copy
    2. Read all the users in a specific OU (eg, 'Year 10'), extract their home directory from active directory
    3. Copy all the files from (1) to (2) in sequence?

    Ive written a lame way of doing it in a batch file but its just not reliable so I need it to read through all the Users in an OU and grab their home directory that way.

    Thanks

  2. #2

    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 copy files to student home directory.

    Whats wrong with doing this in your login scripts?

  3. #3

    Join Date
    Sep 2005
    Posts
    143
    Thank Post
    0
    Thanked 3 Times in 3 Posts
    Rep Power
    19

    Re: Script to copy files to student home directory.

    Thats a good idea, but I think ill run into a similar problem that Im currently getting.
    One of the files is a Database which seems to get screwed up when multiple people start copying at the same time (im guessing it gets locked while a few people are copying it across to their area).

    When its done copying across some people can open it normally and others get 'this database is read only bla bla bla' File permissions are fine for the student after copying and file is not set to read only.

    On top of that, for exam use, id like to have it done and working before the minute the exam starts to find out its not worked.

  4. #4
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    Re: Script to copy files to student home directory.

    1. Ability to browse or change in code, the location of some files, eg d:\files-to-copy
    Not sure what you are asking here please clarify.

    As for the rest.. do you not sort the home directories into year groups eg users\students\year11\. If that is the case you wouldnt need to dive into ad to get the home directories, you already know where they all are and a script could copy whatever into each folder.

  5. #5
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    Re: Script to copy files to student home directory.

    Just had another thought.. if your only problem with your current script is that some files are copied over as read only, maybe what you could do is to change the attrib ie in dos its attrib -r filename.ext.

  6. #6

    Join Date
    Sep 2005
    Posts
    143
    Thank Post
    0
    Thanked 3 Times in 3 Posts
    Rep Power
    19

    Re: Script to copy files to student home directory.

    The permissions/attributes arent a problem, after the file is copied across, the student has full control of the file and the file is not read only, there are no deny permissions. They still get the message that the database is read only.

    Students folders are arranged as intake years (since year 7 turns into year 8 etc), eg d:\users\2001intake (current year 11).

    Not too sure how to get a batch file to loop round all folders inside the intake folder to copy the files though.

    PS I was using 'copy' and have switched to 'xcopy', ive yet to see if this makes a difference

  7. #7

    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 copy files to student home directory.

    no, use robocopy from the resource kit.

  8. #8
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    Re: Script to copy files to student home directory.

    I hope robocopy is useful to you but if you still want to know how to loop through the subdirectories.. heres how you would do it in vbs:

    Code:
    Dim oFS, oFolder, WshShell
    Set WshShell = WScript.CreateObject("WScript.Shell")
    set oFS = WScript.CreateObject("Scripting.FileSystemObject")
    Set oFolder = oFS.GetFolder("c:\browse")
    
    
    ShowFolderDetails oFolder
    
    Sub ShowFolderDetails(oF)
    Dim F
    	for each F in oF.subfolders
    		wshshell.run "c:\windows\system32\xcopy.exe c:\copy\*.* """ & F & "\my documents\"""
    	next
    End Sub
    The script above will go through each subdirectory in c:\browse and then run the xcopy command to copy all files out of c:\copy to the my documents folder in each subdirectory. Change it to suit.

  9. Thanks to apeo from:

    zachariah (30th January 2012)

  10. #9

    Join Date
    Sep 2005
    Posts
    143
    Thank Post
    0
    Thanked 3 Times in 3 Posts
    Rep Power
    19

    Re: Script to copy files to student home directory.

    Thanks.

    Can you modify that slightly so that it will copy them in sequence, ie
    copy files -> folder 1 <wait until done> copy files -> folder 2
    instead of opening multiple instances of xcopy at the same time?

    Just incase I run into the same problem of the database being copied at the same time and locking.

  11. #10
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    Re: Script to copy files to student home directory.

    Code:
    wshshell.run "c:\windows\system32\xcopy.exe c:\copy\*.* """ & F & "\my documents\"""
    Just replace the above code with:

    Code:
    wshshell.run "c:\windows\system32\xcopy.exe c:\copy\*.* """ & F & "\my documents\""",,True
    The additional arguments should tell it to wait untill program terminates. I havent tested it so check it out first be for you run it on your server.

  12. #11

    Join Date
    Sep 2005
    Posts
    143
    Thank Post
    0
    Thanked 3 Times in 3 Posts
    Rep Power
    19

    Re: Script to copy files to student home directory.

    Thanks!
    I really need to read up on vbs scripting, living in the dark ages using batch files!

  13. #12
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    Re: Script to copy files to student home directory.

    NP. VB scripting is useful but i do find myself manipulating other people's code or one i have in a store to suit more than creating it all from scratch. It think its because I dont get to do much scripting that each time i do i need to remind myself of everthing like the libraries, classes.. etc

  14. #13


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339

    Re: Script to copy files to student home directory.

    I really need to read up on vbs scripting, living in the dark ages using batch files!
    VBScript has its uses but I wouldn't go out of my way to learn it. MS have ditched it VBScript. I'd recommend Python as a (beginner) scripting language - it's much more powerful than VBScript. MS have recognised this as they are about to embrace and extinguish python in the form of 'ironpython'.

  15. #14

    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 copy files to student home directory.

    Python help can be got from me btw.

  16. #15

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

    Re: Script to copy files to student home directory.

    Quote Originally Posted by CyberNerd
    VBScript has its uses but I wouldn't go out of my way to learn it. MS have ditched it VBScript. I'd recommend Python as a (beginner) scripting language - it's much more powerful than VBScript. MS have recognised this as they are about to embrace and extinguish python in the form of 'ironpython'.
    Hello ?? Where did you get that from. Microsoft have not ditched VBS. Visual Basic 6 has been ditched in favour of VB.net but these are compiled languages not script interpreters.

    Yes, before someone says it, there is the new MONAD scripting enviroment on the horizon but it will debut on Exchange 12 and then on the Black Comb server. Perhpas there will be a standalone install for 2003 Server and XP. The main thing is VBS will be with us for sometime.

    Before then you could also try KiXtart which is a very popular VBS alternative. It has been customised for system administration so avoid some of the more cumbersome constructions found necessary with VBS.

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

Similar Threads

  1. Mass Copy of Files and Folders
    By originofsymmetry in forum Scripts
    Replies: 6
    Last Post: 2nd October 2007, 12:16 PM
  2. Replies: 6
    Last Post: 11th July 2007, 09:53 PM
  3. Failed to copy files from CD
    By Dos_Box in forum Learning Network Manager
    Replies: 13
    Last Post: 12th April 2007, 10:42 AM
  4. script to copy files to machines
    By browolf in forum Scripts
    Replies: 1
    Last Post: 28th November 2005, 10:28 AM
  5. Replies: 6
    Last Post: 20th October 2005, 06:48 PM

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
  •