Example VBScript source file generated by Macrium Reflect
See also: Generating a VBScript source file
'****************************************************************************** '* '* '* Module Name: Example.vbs '* '* Abstract: This is a template VB Script file generated by Reflect v5.0 '* Modify to add your own functionality if required '* '* '****************************************************************************** OPTION EXPLICIT ' call the main function Call VBMain() '****************************************************************************** '* Sub: VBMain '* '* Purpose: This is main function to start execution '* '* Input: None '* '* Output: None '* '****************************************************************************** Sub VBMain() Dim objShell Dim ExitCode ' Elevate this script for Admin privileges in Vista Elevate Set objShell = WScript.CreateObject("WScript.Shell") ' Do the backup ExitCode = Backup ("""C:\C++\v6\Image\reflect\x64\Debug\reflect.exe"" -e -w <BACKUP_TYPE> ""C:\Example.xml""") ' done Set objShell = nothing wscript.quit(ExitCode) End Sub '****************************************************************************** '* Function: Backup '* '* Purpose: Calls Reflect.exe passing an XML BDF as a parameter '* '* Input: strCmdLine Command Line Arguments '* Output: Exit Code '* '****************************************************************************** Function Backup(Byref strCmdLine) Dim objShell Dim objExecObject Dim iReturnCode strCmdLine = Replace(strCmdLine, "<BACKUP_TYPE>", GetBackupTypeParameter) ' Run the backup or image Set objShell = WScript.CreateObject("WScript.Shell") iReturnCode = objShell.Run(strCmdLine, 1, true) if iReturnCode = 2 then ' Handle XML validation error elseif iReturnCode = 1 then ' Handle backup error elseif iReturnCode = 0 then ' Everything OK end if Backup = iReturnCode Set objShell = nothing End Function '****************************************************************************** '* Sub: Elevate '* '* Purpose: Elevates this script for Vista UAC. '* This means that only one UAC Elevation prompt is displayed and '* functions/programs will not fail if they require admin privileges '* '* Input: None '* Output: None '* '****************************************************************************** Sub Elevate Dim ShellApp Dim objShell Dim objWshProcessEnv ' Don't elevate if run from Windows Task Scheduler If WScript.Arguments.Count > 0 Then If WScript.Arguments.Item(0) = "-s" then Exit Sub End If End If Set objShell = WScript.CreateObject("WScript.Shell") Set objWshProcessEnv = objShell.Environment("PROCESS") If objWshProcessEnv("ELEVATED_APP") <> "True" Then objWshProcessEnv("ELEVATED_APP") = "True" Set ShellApp = CreateObject("Shell.Application") Call ShellApp.ShellExecute("""" & WScript.FullName & """", """" & WScript.ScriptFullName & """" & " " & GetBackupTypeParameter, , "runas") set ShellApp = nothing Set objWshProcessEnv = nothing wscript.quit End If Set objWshProcessEnv = nothing Set objShell = nothing End Sub '****************************************************************************** '* Function: GetBackupTypeParameter '* '* Purpose: determines the backup type from command line parameter '* -full Full backup '* -inc Incremental backup '* -diff Differential backup '* '* Input: None '* Output: the parameter '* '****************************************************************************** Function GetBackupTypeParameter Dim i for i = 0 to Wscript.Arguments.Count - 1 If Wscript.Arguments(i) = "-full" OR _ Wscript.Arguments(i) = "-inc" OR _ Wscript.Arguments(i) = "-diff" Then GetBackupTypeParameter = Wscript.Arguments(i) Exit Function End If Next GetBackupTypeParameter = "" End Function