Step 7Snapshot.vbs explained
Dim FriendlyDateDim FriendlyTimeFriendlyDate = Replace(Date, "/", "-")FriendlyTime = Mid(Replace(Time, ":", "-"), 1, 5)
This creates two variables, FriendlyDate and FriendlyTime, and sets them to the current date and time. The replace functions are there because the date in VBSCript is represented in the form 28/11/2008, but Windows doesn't like the slash characters in a file name, so they are replaced with dashes. The same is done to the : characters in the time (12:34:56). The Mid command also strips off the seconds from the time, so "28/11/2008_12:34:56" becomes "28-11-2008_12-34".
Dim WShellSet WShell = CreateObject("Wscript.Shell")This part is creating a shell object, effectively a command prompt for VBScript, so that it can use command line commands like "move".
WShell.Run ("cmd /c move " + Wscript.Arguments(0) + " .\Backups\" + FriendlyDate + "_" + FriendlyTime + "_" + Wscript.Arguments(0))This tells VBScript to issue a move command to its command line object. To break this line down further would require me to get into the details of how VBScript handles strings so I will refrain from doing that. Essentially, WScript.Arguments(0) becomes the filename you passed to the script earlier (archive.zip) and FriendlyDate and FriendlyTime become the actual text value of the date and time, for instance "18-10-2008" and "14-30". The plus characters join the various bits together into one long string.
The final command that is passed to the command line looks like
move archive.zip .\Backups\18-10-2008_14-30_archive.zip. If you want to save your backups into a different location then you can change the name of the folder from ".\Backups\" to, for instance, "E:\My_Lovely_Version_Control\". If you don't want the time stamps, then you can remove the "+ FriendlyTime" but then only one archive per day can be stored (any further backups will overwrite the existing archive).
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|












































