![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | how-to run sequential copy processes thru vbscript I have a txt file with a to-and-from path on each line( eg.. \ \Svr01\Share01 \\Svr02\Share02). I need to map the folders on 2 different servers and copy each folder sequential because I need to use the same drive letters each time. My script opening several dos boxes at once so it doesn't work. '***** Begin Script *********** EXCLUDEDIRS = "c:\scripts\excludedirs.txt" EXCLUDEFILES = "c:\scripts\excludefiles.txt" ROBOCOPYLOCATION = """C:\Program Files\Windows Resource Kits\Tools \robocopy.exe""" Const FOR_READING = 1 Dim WshShell, objFile, objUserDir Set WshShell = WScript.CreateObject("WScript.Shell") Set FileSys = CreateObject("Scripting.FileSystemObject") On Error Resume Next Set objFile = FileSys.OpenTextFile(EXCLUDEDIRS, FOR_READING) strDirExclude = objFile.ReadAll objFile.Close Set objFile = FileSys.OpenTextFile(EXCLUDEFILES, FOR_READING) strFileExclude = objFile.ReadAll objFile.Close arrDirExclude = Split(strDirExclude, vbCrLf) arrFileExclude = Split(strFileExclude, vbCrLf) On Error Resume Next For Each dir In arrDirExclude dirs = dirs + " /xd " + chr(34) + dir + chr(34) Next For Each bestand In arrFileExclude bestanden = bestanden + " /xf " + chr(34) + bestand + chr(34) Next On Error Goto 0 Set fPath = FileSys.GetFolder("C:\scripts") Set objInputFile = FileSys.OpenTextFile(fPath & "\temp.txt", For_Reading) arrTargets = Split(objInputFile.ReadAll, vbCrLf) objInputFile.Close For Each objLine In arrtargets On Error Resume Next objUserDir = Split(objLine, vbTab) SOURCELOCATION = objLine(0) TARGETLOCATION = objLine(1) mycommand = ROBOCOPYLOCATION & chr(32) & SOURCELOCATION & chr(32) _ & TARGETLOCATION & " /XO /V /E /TEE /MIR /r:0 /w:0 /Log:C:\scripts\" _ & objLine(0) & ".txt" & dirs & bestanden WshShell.Run(mycommand) Next '****** End Script **** |
My System Specs![]() |
| | #2 (permalink) |
| | Re: how-to run sequential copy processes thru vbscript On Sep 10, 8:37*am, indyto...@xxxxxx wrote: Quote: > I have a txt file with a to-and-from path on each line( eg.. \ > \Svr01\Share01 *\\Svr02\Share02). *I need to map the folders on 2 > different servers and copy each folder sequential because I need to > use the same drive letters each time. My script opening several dos > boxes at once so it doesn't work. > > '***** Begin Script *********** > EXCLUDEDIRS = "c:\scripts\excludedirs.txt" > EXCLUDEFILES = "c:\scripts\excludefiles.txt" > ROBOCOPYLOCATION = """C:\Program Files\Windows Resource Kits\Tools > \robocopy.exe""" > Const FOR_READING = 1 > Dim WshShell, objFile, objUserDir > > Set WshShell = WScript.CreateObject("WScript.Shell") > Set FileSys = CreateObject("Scripting.FileSystemObject") > > On Error Resume Next > Set objFile = FileSys.OpenTextFile(EXCLUDEDIRS, FOR_READING) > strDirExclude = objFile.ReadAll > objFile.Close > Set objFile = FileSys.OpenTextFile(EXCLUDEFILES, FOR_READING) > strFileExclude = objFile.ReadAll > objFile.Close > arrDirExclude = Split(strDirExclude, vbCrLf) > arrFileExclude = Split(strFileExclude, vbCrLf) > > On Error Resume Next > For Each dir In arrDirExclude > dirs = dirs + " /xd " + chr(34) + dir + chr(34) > Next > For Each bestand In arrFileExclude > bestanden = bestanden + " /xf " + chr(34) + bestand + chr(34) > Next > > On Error Goto 0 > > Set fPath = FileSys.GetFolder("C:\scripts") > Set objInputFile = FileSys.OpenTextFile(fPath & "\temp.txt", > For_Reading) > > arrTargets = Split(objInputFile.ReadAll, vbCrLf) > objInputFile.Close > > For Each objLine In arrtargets > On Error Resume Next > > objUserDir = Split(objLine, vbTab) > > SOURCELOCATION = objLine(0) > TARGETLOCATION = objLine(1) > > mycommand = ROBOCOPYLOCATION & chr(32) & SOURCELOCATION & chr(32) _ > * * * * & TARGETLOCATION & " /XO /V /E /TEE /MIR /r:0 /w:0 /Log:C:\scripts\" > _ > * * * * * * * * & objLine(0) & ".txt" & dirs & bestanden > WshShell.Run(mycommand) > > Next > > '****** End Script **** split statement. And vbTab is char(9) although I could be wrong. OldDog |
My System Specs![]() |
| | #3 (permalink) |
| | Re: how-to run sequential copy processes thru vbscript <indytoatl@xxxxxx> wrote in message news:ff5e5a11-a2b2-49ba-83e0-a86de94034c7@xxxxxx Quote: >I have a txt file with a to-and-from path on each line( eg.. \ > \Svr01\Share01 \\Svr02\Share02). I need to map the folders on 2 > different servers and copy each folder sequential because I need to > use the same drive letters each time. My script opening several dos > boxes at once so it doesn't work. > [...] > WshShell.Run(mycommand) 'WaitOnReturn' flag: WshShell.Run mycommand, , True |
My System Specs![]() |
| | #4 (permalink) |
| | Re: how-to run sequential copy processes thru vbscript On Sep 10, 4:20*pm, "James Whitlow" <jwhitlow.60372...@xxxxxx> wrote: Quote: > <indyto...@xxxxxx> wrote in message > > news:ff5e5a11-a2b2-49ba-83e0-a86de94034c7@xxxxxx > Quote: > >I have a txt file with a to-and-from path on each line( eg.. \ > > \Svr01\Share01 *\\Svr02\Share02). *I need to map the folders on 2 > > different servers and copy each folder sequential because I need to > > use the same drive letters each time. My script opening several dos > > boxes at once so it doesn't work. > > [...] > > WshShell.Run(mycommand) > * * The remedy to 'opening several dos boxes at once' is to specify the the > 'WaitOnReturn' flag: > > WshShell.Run mycommand, , True Okay Thanks, I tried it with one comma but maybe I needed two. I will test it and comment back. Thanks again |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| vbscript equivalent of copy a+b c | VB Script | |||
| vbscript to copy files from netlog to local profile folder | VB Script | |||
| Copy & paste from IE/FF into a new Outlook email via VBScript | VB Script | |||
| Sequential photo listing | Vista music pictures video | |||
| Sequential File Name Numbering | Vista General | |||