Failure Modes
The Failure Mode allows you to select what happens when a step has an error.
A step may fail for many reasons, such as a file not existing, an incorrect parameter, or even as a planned failure.
The Failure Mode options are:
- Display Error and Stop: Shows a message box with a warning icon, and the script immediately stops at its current location
- Display Error and Continue: Shows a message box with a warning icon, and continues execution normally after the warning
- Ignore/Continue: Does not display any message, and execution continues normally (a warning is shown in the Output window)
- Retry the Step x Times: Will re-run the same step that failed a number of times that you indicate
- Stop Silently: The script immediately stops at its current location, but without showing any warning message
- Ask to Continue: Shows a message box with a warning icon, and the script will continue if the user chooses the "Continue" option
- Jump to Label: Continues execution at the Label indicated, and no warning is shown
- Increment Variable: Adds 1 to a variable that you indicate, and execution then continues normally.
Variables from external VXM scripts will appear in the list only after they have been run once. Variables from the current script will be loaded as soon as they are used anywhere in the script.
- Restart Run: Starts script execution from the first step
- Run Program: Launches a program and stops script execution. It can start a program (EXE), a document, or a website. The command line also accepts parameters, such as "%WINDIR%\notepad.exe readme.txt"
If the error occurs while running a child script, the result will be the same as if the child script terminated, and the parent will continue execution.
On Failure: Write to Log: This option writes the error text to the logfile, even if logging is not currently turned on.
See the Log/Reports Options section for information concerning the location of the logfile.
On Failure: Screenshot: This option will take a snapshot of the entire screen in .BMP format, and save it to the same location as the logfile.
See the Log/Reports Options section for information concerning the location of the logfile.
The filename of the screen image will include the step number, and the date/time stamp that the error occurred.
Checking for Failures in Called Scripts
When any script fails, it sets the {failstep} system variable to the number of the step that had an error.
This variable is reset each time a run is started.
If no failure occurred, the variable will be 0 (or undefined).
This allows you to check the error/success of called scripts from a parent script.
Example:
Script 1:
Script 2:
Script #1 will call Script #2, which will fail (silently or visibly). Script #1 determines that the called script (#2) failed, and can act appropriately (stop, warn, etc). This should allow you to handle all possibilities for parent script error handling. As a side benefit of how it was implemented, you can also modify the value directly yourself, as it is stored in the registry under SOFTWARE\vTask\FailStep. This was necessary since multiple separate processes will need to access it, and it acts as a global variable.