' copy file or files to lots of computers ' Chris Erwin dim SchoolFileName dim FileName dim MoveToPath SchoolNumber = 80 ' forces scope to global to avoid passing around amongst the functions. I know, bad practice, but it's vbscript, so shaddap Set fso = CreateObject("Scripting.FileSystemObject") ' a file system object Const ForReading = 1, ForWriting = 2, ForAppending = 8 ' This makes no sense... FileName = InputBox("file name to be moved:","pick a file:") if FileName = "" then WScript.Quit ' cancel to quit MoveToPath = InputBox("path to which to move the file, after\\compname\c$\ (e.g. districtapps\folder\):","move to:") if MoveToPath = "" then WScript.Quit Do SchoolFileName = InputBox("text file containing computer names:","name list:") if SchoolFileName = "" then WScript.Quit Loop While SchoolFileName = FileName ' cannot copy the same file you're pulling computer names from. I guess it's not a necessary check... Set objCompList = fso.OpenTextFile(SchoolFileName, ForReading) Do LogFileName = InputBox("file name for log:","log file:") if LogFileName = "" then WScript.Quit Loop While LogFileName = FileName Or LogFileName = SchoolFileName ' cannot leave logs in the other important files. this IS necessary. Set objLogFile = fso.CreateTextFile(LogFileName, TRUE) ' true is for overwriting. careful! objLogFile.WriteLine("log for " & Now) ' timestamp the log WScript.Echo "Press OK to Begin. Please Wait for the All Done! message, you impatient fool." ' no feedback in vbscript that doesn't wait for user input. stupid. Do While Not objCompList.AtEndOfStream ' do while not at the end of the file On Error Resume Next ' keeps script from whining about errors. that's what the log is for. LineReader = objCompList.ReadLine ' read a line from file into LineReader LineParser ' calls the line parsing function Loop ' dance monkey! WScript.Echo "All Done!" function LineParser() ' determine what the line means, and do something with that If Len(LineReader)=2 then ' if there are only two characters on the whole line, then it's a school number SchoolNumber=LineReader ElseIf Mid(LineReader,3,1)="-" then ' if the third character is a dash, then it's a whole computer name (or user error, which is not my problem, so nyah) FNameS = "\\" & LineReader & "\c$\" & MoveToPath ' build up the path string CopyFile(FNameS) ' yeah... Else Room = Split(LineReader," ") ' if it wasn't one of those other two things, it had better be a room and number of computers (### ##), or else again, not my problem. RoomNumber = Room(0) ' good, vbscript arrays are indexed correctly. woohoo! NumComps = Room(1) for i = 1 to NumComps if i < 10 Then iFixed = "0" & i ' 80-lib-1 becomes 80-lib-01 Else iFixed = i ' no need for 0 if the computer number is more than 09 End If CompName = SchoolNumber & "-" & RoomNumber & "-" & iFixed ' build up computer name FNameS = "\\" & CompName & "\c$\" & MoveToPath ' and then the path CopyFile(FNameS) ' mhmm Next End If end function function CopyFile(FNameS) ' read the function name, jerk fso.CopyFile FileName, FNameS, True ' WScript.Echo FNameS (for debugging) objLogFile.WriteLine ("copied " & FileName & " to " & FNameS) ' dear diary... objLogFile.WriteLine (Err.Number & Err.Description) end function