Support
Dedicated Knowledge Base
Article | 175 | |
Title | VBScript to archive files | |
Content |
Option Explicit Dim arg Set arg = WScript.Arguments Dim sh Set sh = CreateObject("WScript.Shell") Dim fso Set fso = CreateObject("Scripting.FileSystemObject") Dim sFile Dim sFolder Select Case arg.Count Case 2 sFile = arg.Item(0) & ".zip" sFolder = arg.Item(1) Case 4 If arg.Item(2) = "w" Then sFile = arg.Item(0) & "_w" & DatePart("w", Now) Mod arg.Item(3) & ".zip" sFolder = arg.Item(1) ElseIf arg.Item(2) = "ww" And Weekday(Now) = 1 Then sFile = arg.Item(0) & "_ww" & DatePart("ww", Now) Mod arg.Item(3) & ".zip" sFolder = arg.Item(1) Else WScript.Echo "Weekday(Now) <> 1" WScript.Quit (0) End If Case Else WScript.Echo "args s/b: file folder w/ww mod" WScript.Quit (0) End Select If fso.FileExists(sFile) Then fso.DeleteFile(sFile) Dim sCmd ' sCmd = "wzzip -arP " & sFile & " " & sFolder ' sCmd = "C:\Sites\LocalUser\brad\bin\zip.exe -r -f -q " & sFile & " " & sFolder ' sCmd = "/cygwin/c/Sites/LocalUser/brad/bin/zip.exe -r -f -q " & sFile & " " & sFolder sCmd = """C:\Program Files\7-Zip\7z"" a -tzip -r " & sFile & " " & sFolder WScript.Echo sCmd 'sh.Exec(sCmd) Dim iRtn iRtn = sh.Run(sCmd, 1, true) | |
Modified Date | 3/24/2006 |