<package>
<job id="vbs">
<script language="VBScript">
'USER DEFINED VARIABLES
'If you need to modify this script to use your own file locations,
'you can modify the paths here. You must do this with all of the
'applicable scripts.
'This is where you want the "shared" library to live. It must be
'on a network drive that can be accessed by all the machines that will
'be synced by the scripts. Be sure to include the trailing "\" as part
'of the path you give.
strSharedLibraryDir = "M:\library_data\"
'This is where each machines' local library will live. This must be
'the same for all the computers using these scripts and it must exist.
'Again, be sure to include the trailing "\".
strLocalLibraryDir = "C:\library_data\"
'This is the name of your library in MC. This is what the subfolder
'containing your library inside the above directories will be called.
strLibraryName = "andoria"
'This is where you've installed these scripts.
strMyDirectory = "O:\Users\Shared\scripts\MC_Scripts\"
'This is where the zg.exe file is located. This should be inside the ZipGenius6
'folder. If you haven't installed ZipGenius6, it is required for this archive
'script to work properly. You can download it for free from here:
'http://zipgenius.it
'It's a great, completely free WinZip alternative (much more powerful too)!
strZGLocation = "C:\Program Files\ZipGenius 6\zg.exe"
'END USER DEFINED VARIABLES
'ALL USER DEFINED VARIABLES ARE ABOVE THIS LINE
'DON'T MODIFY ANYTHING BELOW HERE
'Create our handy dandy Shell object
set WshShell = WScript.CreateObject("WScript.Shell")
'We also need a FileSystemObject object
set FileSys = CreateObject("Scripting.FileSystemObject")
'Handy Variables
strMyName = "MC_Library-Archive"
strSharedLibrary = strSharedLibraryDir & strLibraryName
strSharedBackup = strSharedLibraryDir & "backup\"
strLocalLibrary = strLocalLibraryDir & strLibraryName
strLocalBackup = strLocalLibraryDir & "backup\"
strExcludeFile = strMyDirectory & "exclude.txt"
strLogFile = strSharedLibraryDir & "ScriptLog.txt"
strPublishedFlag = strSharedLibraryDir & "published.flag"
'This is the text used by XCOPY to create the datestamp in the file name with options
strBackupNameText = strLibraryName & "-backup-%date:~10,4%%date:~4,2%%date:~7,2% /E /C /I /H /Y /EXCLUDE:"
'Special Archive Variables
strBackupZipFile = strSharedLibraryDir & "backup.zip"
strFinalZip = strSharedLibraryDir & strLibraryName & "-backup_%date:~10,4%%date:~4,2%%date:~7,2%.zip"
strBackupSpec = strSharedBackup & "*.*"
'Check for "/verbosity:on" argument
set colNamedArguments = WScript.Arguments.Named
If colNamedArguments.Exists("verbosity") then
'Assign the value to the strVerbosity variable and check to see if it's valid
strVerbosity = colNamedArguments.Item("verbosity")
if not (strVerbosity = "on" or strVerbosity = "off") then
WshShell.Popup strMyName & " ERROR:" & VbCrLf & VbCrLf & "/verbosity option given with invalid value. Available values are ""on"" or ""off"". Value given was: " & strVerbosity, 15, , vbExclamation
WshShell.Run "%comspec% /c echo %COMPUTERNAME% : " & strMyName & " failed (invalid /verbosity): %DATE% %TIME% >> " & strLogFile, 0, False
WScript.quit
end if
else
'Set strVerbosity to the default value of off
strVerbosity = "off"
end if
'SCRIPT ACTUALLY STARTS DOING STUFF HERE
'Note start time in the Log
WshShell.Run "%comspec% /c echo %COMPUTERNAME% : MC Archive started: %DATE% %TIME% >> " & strLogFile, 0, False
'Check to see if ZipGenius is installed
If Not FileSys.FileExists(strZGLocation) then
WshShell.Popup strMyName & " ERROR:" & VbCrLf & VbCrLf & "ZipGenius does not appear to be installed! Archive operation will not be enabled." & VbCrLf & VbCrLf & "To download and install the free ZipGenius utility, visit: http://zipgenius.it/", 15, , vbExclamation
WshShell.Run "%comspec% /c echo %COMPUTERNAME% : " & strMyName & " failed (ZipGenius6 not present): %DATE% %TIME% >> " & strLogFile, 0, False
WshShell.Run "%comspec% /c echo %COMPUTERNAME% : To download the free ZipGenius utility, please visit http://zipgenius.it/ >> " & strLogFile, 0, False
WScript.quit
else
WshShell.Run "%comspec% /c echo %COMPUTERNAME% : " & strMyName & " located ZipGenius6: %DATE% %TIME% >> " & strLogFile, 0, False
end if
'Kill off any old backups you find hanging out.
WshShell.Run "%comspec% /c rmdir /S /Q " & strSharedBackup, 0, True
WshShell.Run "%comspec% /c rmdir /S /Q " & strLocalBackup, 0, True
'Make a backup of the current Shared Library
WshShell.Run "%comspec% /c xcopy " & strSharedLibrary & " " & strSharedBackup & strBackupNameText & strExcludeFile, 0, True
'Deleting the old leftover backup.zip file, if it exists
if FileSys.FileExists(strBackupZipFile) then
FileSys.DeleteFile strBackupZipFile, True
end if
'Run the ZipGenius task
WshShell.Run "zg.exe -add """ & strBackupZipFile & """ C9 R1 +""" & strBackupSpec &"""", 7, True
'Copy the file over to what it should be called long term, then delete the temp one
WshShell.Run "%comspec% /c copy /Y " & strBackupZipFile & " " & strFinalZip, 0, True
if FileSys.FileExists(strBackupZipFile) then
FileSys.DeleteFile strBackupZipFile, True
end if
'If the user asked for a popup message (via the /verbosity:on command line option) then give them one
if (strVerbosity = "on") then
WshShell.Popup strMyName & " finished!", 5, , vbInformation
end if
'Note end time in the Log
WshShell.Run "%comspec% /c echo %COMPUTERNAME% : " & strMyName & " finished: %DATE% %TIME% >> " & strLogFile, 0, False
</script>
</job>
</package>