Kaseya Community

How to End a Script when using Sub Scripts

  • Can anyone suggest how this can be done.

    From a main script I want to be call a number of sub scripts that check certain conditions (that's easy). Each of the sub scripts is a conditionalIf Then Else, & I want the Else branch to end the script. If all of the conditions are met the final script is executed. If any of the conditions in the sub scripts fail the script ends.

    I have outlined the script structure below.

    If

    Then



    If

    Then

    Else



    If

    Then

    Else



    If

    Then

    Else



    If

    Then

    Else



    run admin task

    Else




    Legacy Forum Name: How to End a Script when using Sub Scripts,
    Legacy Posted By Username: TechOnline
  • In case anyone is wondering, I had a separate discussion with Kaseya support on this issue.

    In short the answer is no, you cannot end a script using a called script. You can only end a script by returning & then completing the calling script. The Kaseya recommendation is to use nested scripts instead.

    I understand that you can use nested scripts to achieve the result, but this has disadvantages. I prefer to try and break scripts up into reusable components & then you can reuse the same script by calling it from a number of different master scripts.

    If you use nested scripts you cannot do this because each set of nested scripts is dedicated to a particular set of tasks & it is not very easy to reuse the nested scripts with other calling scripts.

    If Kaseya scripting had an function this would solve the problem. I am no scripting expert, but scripting languages I am familiar with do have this capability.




    Legacy Forum Name: Script Discussion,
    Legacy Posted By Username: TechOnline