Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - how-to run sequential copy processes thru vbscript

Reply
 
Old 09-10-2008   #1 (permalink)
indytoatl


 
 

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 SpecsSystem Spec
Old 09-10-2008   #2 (permalink)
OldDog


 
 

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 ****
I am thinking you need to use char(13) rather than vbCrLf in your
split statement. And vbTab is char(9) although I could be wrong.

OldDog
My System SpecsSystem Spec
Old 09-10-2008   #3 (permalink)
James Whitlow


 
 

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)
The remedy to 'opening several dos boxes at once' is to specify the the
'WaitOnReturn' flag:

WshShell.Run mycommand, , True


My System SpecsSystem Spec
Old 09-11-2008   #4 (permalink)
indytoatl


 
 

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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46