Frazer Posted March 29, 2006 Posted March 29, 2006 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
Frazer Posted March 29, 2006 Author Posted March 29, 2006 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.
apeo Posted March 29, 2006 Posted March 29, 2006 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.
apeo Posted March 29, 2006 Posted March 29, 2006 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.
Frazer Posted March 29, 2006 Author Posted March 29, 2006 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
apeo Posted March 29, 2006 Posted March 29, 2006 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: 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. 1
Frazer Posted March 30, 2006 Author Posted March 30, 2006 Thanks. Can you modify that slightly so that it will copy them in sequence, ie copy files -> folder 1 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.
apeo Posted March 30, 2006 Posted March 30, 2006 wshshell.run "c:\windows\system32\xcopy.exe c:\copy\*.* """ & F & "\my documents\""" Just replace the above code with: 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.
Frazer Posted March 30, 2006 Author Posted March 30, 2006 Thanks! I really need to read up on vbs scripting, living in the dark ages using batch files!
apeo Posted March 30, 2006 Posted March 30, 2006 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
CyberNerd Posted March 30, 2006 Posted March 30, 2006 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'.
NetworkGeezer Posted March 30, 2006 Posted March 30, 2006 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.
CyberNerd Posted March 30, 2006 Posted March 30, 2006 I wasn't saying it was completely useless, just that if someone was about to embark on leaning a new language then there are better options than VBScript. python/perl/js/php have a brighter future. VBScript will indeed be with us for some time, but so will many outdated things. Things move on, VBscript won't.
NetworkGeezer Posted March 30, 2006 Posted March 30, 2006 @Geoff and CybNerd Your advocacy of FLOSS is commendable and in an ideal world it would be nice to have Python or C/Z/BA/SH installed by default on everybodys favourite monoply OS but if you admin a Windows network then knowledge of VBS is probably more useful. Out of interest does anybody here run Python login scripts?
Geoff Posted March 30, 2006 Posted March 30, 2006 IronPython isn't quite FLOSS. And yes, I have some Python stuff.
fooby Posted June 20, 2006 Posted June 20, 2006 Didnt see this post, however I have a solution to this on this http://edugeek.net/index.php?name=Forums&file=viewtopic&t=3203 fooby
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