Example of using the VBScript package in a resilient automation
- Updated: 2025/11/03
Build an automation that executes a Microsoft Visual Basic script. Use the package to end the automation if it fails, making it resilient to deployment failures. A resilient automation allows scheduled and queued tasks to continue even when it encounters any deployment errors.
Procedure
-
Create Task Bot.
-
On the left panel, click Automation.
A list of available automations and forms is displayed.
- Click Create New > Task Bot.
- Provide a name for the Task Bot: MultiplyPi
- Click Create and Edit.
-
On the left panel, click Automation.
-
Create the following variables:
- First variable
- Name: nPromptAnswer
- Type: Number
- Second variable
- Name: lNumbersForPi
- Type: List
- Subtype: Number
For more information on creating a variable, see Create a variable. - First variable
- Click Save.
-
Use the For value
action to prompt the user for a number.
- Double-click or drag the Prompt > For value action to add it to the automation.
- In the Prompt window caption field, enter Any Number.
- In the Prompt message field, enter Enter any number to multiply by pi.
- Click the Assign the value to a variable drop-down menu and select SampleString.
- Click Save.
-
Use the Try
action to end the automation if the user does not enter a number when
prompted.
- Double-click or drag the Error handler > Try action.
- Drag the Prompt > For value action under the Error handler > Try action.
- Click Save.
-
Convert the SampleString (string) to a number value.
- Double-click or drag the String > To number action, adding it as the last line before the Error handler > Catch action.
- In the Enter the string field, press F2 to open the list of your variables, and select SampleString.
- Click Insert.
- Click the Assign the output to variable drop-down menu and select nPromptAnswer.
- Click Save.
-
Copy the number value to the first item in the list of numbers to pass to
VBScript.
- Double-click or drag the List > Add item action to the last line before the Error handler > Catch action.
- Click the List variable drop-down menu and select lNumbersForPi.
- Click the Item to be added drop-down menu and select nPromptAnswer.
- Click Save.
-
Use the Open
action to provide your Visual Basic source code.
- Double-click or drag the VBScript > Open action to the last line before the Error handler > Catch action.
- In the VBScript field, select the Manual Input radio button.
-
Copy the following code and paste it into the Enter script
here field:
Dim Arg, var1, var2 Set Arg = WScript.Arguments Function MultiplyPi(Arg) var1 = Arg(0) var2 = 3.14159 MultiplyPi = cdbl(var1)*var2 End Function - Click Save.
-
Use the Run function
action to execute the script.
- Double-click or drag the VBScript > Run function action to the last line before the Error handler > Catch action.
- In the Enter the name of the function to be executed (optional) field, enter MultiplyPi.
- Click the Parameters (optional) drop-down menu and select lNumbersForPi variable.
- Click the Assign the output to variable (optional) drop-down menu and select SampleString.
- Click Save.
-
Use the Close
action to end the session.
- Double-click or drag the VBScript > Close action to the last line before the Error handler > Catch action.
- Click Save.
-
Display the answer generated in the VBScript on the screen.
- Double-click or drag the Message box action to the last line before the Error handler > Catch action.
- In the Enter the message to display field, enter Pi times your number is:.
- Press F2 to open the list of your variables, and select SampleString.
- Click Insert.
- Click Save.
-
Notify the user if an error occurred before terminating the automation.
- Double-click or drag the Message box action under the Error handler: Catch AllErrors.
- In the Enter the message to display field, enter Bot failed. Please be sure to enter only numbers..
- Click Save.
-
Click the List tab to view your code as text only.
Your code should look like this:
Start Error handler: Try Prompt: For value during bot execution and assign the value $SampleString$ String: To number Convert string $SampleString$ to a number and assign it to number variable $nPromptAnswer$ List: Add item $nPromptAnswer$ to $lNumbersForPi$ VBScript: Open VBScript manual script of 7 lines VBScript: Run function "MultiplyPi" VBScript: Close VBScript "Default" Message box "Pi times your number is: $SampleString$" Error handler: Catch AllErrors Message box "Bot failed. Please be sure to enter only numbers." End -
Run your automation.
When the automation is deployed, the prompt window opens where you enter the value, and then the message box displays the calculated number.


-
Click Close
You can test the resiliency of your Task Bot by running it again and entering a string value instead of a number when prompted.