Whats wrong with doing this in your login scripts?
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.
Whats wrong with doing this in your login scripts?
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.
Not sure what you are asking here please clarify.1. Ability to browse or change in code, the location of some files, eg d:\files-to-copy
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.
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.
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
no, use robocopy from the resource kit.
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:
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.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
zachariah (30th January 2012)
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.
Just replace the above code with:Code:wshshell.run "c:\windows\system32\xcopy.exe c:\copy\*.* """ & F & "\my documents\"""
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.Code:wshshell.run "c:\windows\system32\xcopy.exe c:\copy\*.* """ & F & "\my documents\""",,True
I really need to read up on vbs scripting, living in the dark ages using batch files!
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
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'.I really need to read up on vbs scripting, living in the dark ages using batch files!
Python help can be got from me btw.
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.Originally Posted by CyberNerd
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)