Hi
I am trying to create a VBScript that will go through log files on a server, then move it to an archive location if older than one day.
I am new to VBS, however I used Visual Basic back in 98 so I may still have some logic building skills but as far as vbs understanding I may not be very sharp.
Here is the flow chart
1. Zip one file at a time.
2. Check archive integrity.
3. Delete original log file after the zip file is created then checked for integrity.
What I have so far is I am able to zip the files and delete it. but I am unable to check the integrity before deleting. I am not sure if the switches -m and -T will be sufficient, also I am unable to get any output of the commands to the screen so that I can capture it in a log file.
I am trying to create a VBScript that will go through log files on a server, then move it to an archive location if older than one day.
I am new to VBS, however I used Visual Basic back in 98 so I may still have some logic building skills but as far as vbs understanding I may not be very sharp.
Here is the flow chart
1. Zip one file at a time.
2. Check archive integrity.
3. Delete original log file after the zip file is created then checked for integrity.
What I have so far is I am able to zip the files and delete it. but I am unable to check the integrity before deleting. I am not sure if the switches -m and -T will be sufficient, also I am unable to get any output of the commands to the screen so that I can capture it in a log file.
Code:
************************************************
' Setting the Variables used in the Loop
Dim CurDate, CurTime, dn
Dim ObjLOG, ObjShellLOG, ObjLOGFolder, LOGHome
Dim ObjLOGCollection, ObjLOGFile, LOGModDate, LOGAge, LOGFileName
Dim StrFileLOG, StrCMDLOG, StrRunLOG
Dim CheckZipLOG
'set the datetime parameter
CurDate = Replace (FormatDateTime(Date, 2), "/", "-")
CurTime = Replace (FormatDateTime(Time(), 4), ":","")
dn = CurDate &CurTime
LOGHome = "D:\Logs\"
Set ObjLOG = CreateObject("Scripting.FileSystemObject")
Set objShellLOG = wscript.createObject("wscript.shell")
Set ObjLOGFolder = ObjLOG.GetFolder(LOGHome)
Set ObjLOGCollection = ObjLOGFolder.Files
'loop that will go through the files one at a time and zip it
For Each ObjLOGFile In ObjLOGCollection
LOGModDate = ObjLOGFile.DateLastModified
LOGFileName = ObjLOGFile.Path & "-" & dn & ".zip"
LOGFileName = replace (LOGFileName, " ","")
LOGAge = datediff ("d", LOGModDate, Now())
StrFileLOG = ObjLOGFile.Path
strFileLOG = replace (StrFileLOG, " ","*")
StrCMDLOG = "zip " & LOGFileName & " " &StrFileLOG & " >> d:\docs\logs.txt"
if LOGAge > 1 Then
strRunLOG = objShellLOG.Run(strCMDLOG, 0, True)
wscript.echo err.number
End If
Next