Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

Robocopy Help needed

$
0
0
Could someone help me out with the best way to have a script that will allow me to enumerate a txt file for multiple source, target, log path and log names? Currently i run anywhere from 2 to 6 robocopy sessions of the following script at any given time. it sucks having to to enter the source, target, log path and log names for each session, i figure it would be better to just have it pull the information from a txt file.

Code:

Set objShell = CreateObject("Wscript.Shell") 
objSource = InputBox("Please enter the Path to the source Data: Example:  \\Hostname\c$", _
    "Source Folder")
If objSource = "" Then
    Wscript.Quit
Else
    MsgBox objSource, 0, "Source Path"
End If

objDestination = InputBox("Please enter the Path to Destination Folder: Example:  C:\Target\Data", _
    "Destination Folder")
If objDestination = "" Then
    Wscript.Quit
Else
    MsgBox objDestination, 0, "Target Path"
End If

objlogpath = InputBox("Please enter the Path and name where the log will be placed: Example:  C:\script_path\hostname.txt", _
    "Path and log name")
If objlogpath = "" Then
    Wscript.Quit
Else
    MsgBox objlogpath, 0, "Log Path"
End If

objcmd = "Robocopy"
objSource = """" & objSource & """"
objDestination = """" & objDestination & """"
objswitches = " /B /S /COPY:DATO /DCOPY:T /R:2 /W:5 /V /TEE"
objlogpath = "/log:" & objlogpath

objCommand = objcmd & Chr(32) & objSource & Chr(32) & objDestination & Chr(32) & objswitches & Chr(32) & objlogpath
Wscript.echo objCommand
objShell.Run(objCommand) 
MsgBox "Robocopy has been executed"

Below is what i am basically doing

robocopy "Source1" "target1" /mir /tee /log:"logpath\log1.txt"
robocopy "logpath" "logpath2" "log1.txt" /B /S /COPY:DATO /DCOPY:T /R:2 /W:5 /V /TEE

robocopy "Source2" "target2" /mir /tee /log:"logpath\log2.txt"
robocopy "logpath" "logpath2" "log2.txt" /B /S /COPY:DATO /DCOPY:T /R:2 /W:5 /V /TEE

robocopy "Source3" "target3" /mir /tee /log:"logpath\log3.txt"
robocopy "logpath" "logpath2" "log3.txt" /B /S /COPY:DATO /DCOPY:T /R:2 /W:5 /V /TEE

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>