Manually customize a VBScript

To edit a VB Script

  1. Create a VBScript file using the defaults. See VBScript Generation Options

  2. In the Macrium Reflect main window, click the VBScript files tab.

    A list of VBScript source files appears.

  3. Select a source file.

    The VBScript contents appear in the lower half of the window with syntax highlighting to help you read the code.

  4. Right-click the VBScript file and select Edit from the shortcut menu.

    This opens the source file in your default text editor, the Windows default is Notepad.exe. Make sure that Word Wrap is turned off.

  5. Locate a line of code similar to:

    ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w  <BACKUP_TYPE>  ""C:\Users\Annette\Reflect\C Full Image.xml""")

  6. And replace it with your code. For example:

    If Weekday(Date) = 2 AND Month(DateAdd("d", -7, Date)) <> Month(Date) Then
     ' Run the full image
     ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w ""C:\Users\Annette\Reflect\C Full Image.xml""")
    Else
     ' Run the Incremental image
     ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w ""C:\Users\Annette\Reflect\C Incremental Image.xml""")
    End If


    Where:

    - Date is the current system date.
    - The Weekday function returns the day of the week as a number. That is, 1 = Sunday, 2 = Monday and so on.
    - The DateAdd method is used to subtract 7 days from the current date. Where, "d" represents days. Other possibilities include, "yyyy" for Year, "q" for Quarter, "m" for Month, "y" for Day of year, "w" for Weekday, "ww" for Week of year, "h" for Hour, "n" for Minute, "s" for Second.
    - Month returns the month (1-12) of the DateAdd result and compares this with the current month using the not equal to '<>' operator.
    - The logic tests to see if the current day is Monday and the Monday of last week is a different month, if it is, then this is the first Monday of the current month. The code then executes the XML backup definition file for the full image otherwise, the incremental XML definition is executed.

  7. When you have made the changes, save the file and close Notepad.

  8. Schedule the VBScript file to run every weekday. Execute or schedule the VBScript source file in exactly the same way as a backup definition file . See Schedule backups.

  9. To learn more about VBScript we suggest that you experiment with the options in the generator. It generates separate functions for each option and provides code comments to help you understand them. You can also find reference information for all the VBScript functions on the external website, http://www.w3schools.com/VBscript/vbscript_ref_functions.asp.