Option Explicit
'Declare Variables
Dim objFSO,objWSHShell,objInFile,objFolder,objFile,objZipFolder,objZipFile,objLogFile
Dim strDate,strMonth,strYear,strDay,strTargetFile1,strTargetfile2,strDeleteDate
Dim strServer,strImageLib,strPrimaryWS,strVirtualWS,strStage,strSyntax,strExt,strZip
Dim arrWebServerList,strFolder1,strFolder2,strFolder3,strFolder4,strFolder5,strFile1
Dim strFile2,strFile3,strMovefile,strNetUse,strSource,strOutFile
'Set Objects
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWSHShell = CreateObject("WScript.Shell")
Set objInFile = objFSO.OpenTextFile("C:\scripts\WebServerList.txt")
'Determin Target Date
strDate = Now()-1
strMonth = CStr(Month(strDate))
strYear = Right(CStr(Year(strDate)),2)
strDay = CStr(Day(strDate))
'If Month Single Digit then pad with leading zero
If Len(strMonth) = 1 Then
strMonth = "0" & strMonth
End If
'If Day Single Digit then pad with leading Zero
If Len(strDay) = 1 Then
strDay = "0" & strDay
End If
'Determin Target Files
strTargetFile1 = "ex" & strYear & strMonth & strDay & ".zip"
strTargetfile2 = "ex" & strYear & strMonth & strDay & ".log"
'Target Delete Date
'strDeleteDate = Date -32
'Read Web Server List
Do While Not objInFile.AtEndOfStream
arrWebServerList = Split(objInFile.ReadLine,",")
strServer= arrWebServerList(0)
strImageLib = arrWebServerList(1)
strPrimaryWS = arrWebServerList(2)
strVirtualWS = arrWebServerList(3)
strStage = "D:\" & strServer & "\"
strZip = "c:\winzip\winzip32"
strFile1 = strPrimaryWS & strTargetfile2
strFile2 = strVirtualWS & strTargetfile2
strFile3 = strImageLib & strTargetfile2
'Authenticate to Web Server
strNetUse = "cmd /c netuse \\" & strServer & (Login information for server)
objWSHShell.Run strNetUse,0,True
'Zip file Exist on Server
If objFSO.FileExists ("\\" & strServer & "\D$\Logs\ZipFiles\" & strTargetFile1) Then
Set objFile = objFSO.GetFile("\\" & strServer & "\D$\Logs\ZipFiles\" & strTargetFile1)
'Copy zip file From WebServer
objFOS.Copyfile objFile.Path, strStage & "\"
'UnZip File to Local Directory
strSyntax = strZip & " -e " & stgStage & "\" & strTargetFile1 & " " & "C:\"
objWSHShell.Run strSyntax,0,True
'Move File to Destination Directory
If objFSO.FileExists ("c:\" & strFile1) Then
objFSO.MoveFile strStage & strPrimaryWS & "\"
If objFSO.FileExists ("c:\" & strFile2) Then
objFSO.MoveFile strStage & strVirtualWS & "\"
If objFSO.FileExists ("c:\" & strFile3) Then
objFSO.MoveFile strStage & strImageLib & "\"
Elseif strExt = ".zip" Then
objFSO.MoveFile objLogFile.Path,strStage & "completedZips\"
'Disconnect From Web Server
strNetUse = "cmd /c netuse \\" & strServer & /d"
objWSHShell.Run strNetUse,0
End If
Loop