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

Merging multiple logs in a robocopy script

$
0
0
Wondering if someone can help me figure out what i may be doing wrong towards the end of my script when merging the log files. for some reason i cant figure out on how to trap the objlogpath that was previously sent to robocopy and use it as a feeder when mergingthe logs. also i wanted the merged log in the same directory that the original robocopy log was created in "objlogpath"

it works when i enter the full path for when it reads the log, but wont work when i use the objlogpath. dont be too mean to me guys this is my 4th month trying to learn VB Scripting.


Code:

Set objShell = CreateObject("Wscript.Shell")

MsgBox "Test Script", vbOKOnly, "Test Script" 

objSource = InputBox("Please enter the Path to the source Data: Example:  C:\Source\Data", _
    "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 of the existing log folder: Example:  C:\LogFolder\logname.txt" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "LOG FILE MUST HAVE A .TXT EXTENSION", _
    "Log Path and Folder Folder")
If objlogpath = "" Then
    Wscript.Quit
Else
    MsgBox objlogpath, 0, "Log Path"
End If

objcmd = "Robocopy"
objSource = """" & objSource & """"
objDestination = """" & objDestination & """"
objdate = "" & objdate & ""
objswitches = " /MIR /S /A-:SH /R:2 /W:5 /V /TEE /XJ "

ExcludeDir = Chr(32) & Chr(34) & "ProgramData" & Chr(34)

objExcludeDir = "/XD" & ExcludeDir

IncludeFile = Chr(32) & Chr(34) & "*.asd" & Chr(34) & Chr(32) & Chr(34) & "*.docm" & Chr(34)
objIncludeFile = "/IF" & IncludeFile

objlogpath = "/log+:" & objlogpath

objCommand = objcmd & Chr(32) & objSource & Chr(32) & objDestination & Chr(32) & objswitches & Chr(32) & objExcludeDir & Chr(32) & objIncludeFile & Chr(32) & objlogpath

MsgBox objcmd & Chr(32) & objSource & Chr(32) & objDestination & Chr(32) & objswitches & Chr(32) & objlogpath, 0, "Command Being sent to RoboCopy"

objShell.Run objCommand,1,True

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("network.txt", True)

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
objFile.WriteLine "Computer: " & strComputer

userName = objNetwork.UserName 
objFile.WriteLine "" & objNetwork.UserName;

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = objFSO.CreateTextFile =objlogpath +1

Set objTextFile = objFSO.OpenTextFile("network.txt", ForReading)

strText = objTextFile.ReadAll
objTextFile.Close
objOutputFile.WriteLine strText

Set objTextFile = objFSO.OpenTextFile = objlogpath, ForReading)

strText = objTextFile.ReadAll
objTextFile.Close
objOutputFile.WriteLine strText

objOutputFile.Close

MsgBox "Your Collection has completed Sucessfully", 0, "Test Script"


Viewing all articles
Browse latest Browse all 688

Trending Articles



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