Kaseya Community

Script fails

This question is not answered

Extremely simple question.

Example 1:  Display message within else statement - Script works - Displays pop-up 'test'

Example 2: Display message outside the else statement - Script fails THEN step 5 - No pop up displayed

 Ok. Even though there is not a chance on earth there is a "logical" explanation to this problem, I expect there IS an answer. 

All Replies
  • What does the Agent Procedure Log say? Usually it has a little bit more explanation in there.

    I have run into similar problems when trying to use variables across if/else statements. My theory is Kaseya treats each of these statements as separate scripts behind the scenes and they are not aware of variables created by the others. I could be wrong though.

    [edited by: SMason at 1:07 PM (GMT -7) on 8-4-2011] Added a missing word?
  • What the hell. What kind of sense does that make? I just tested your theory and it appears it is correct.

    How in the world am I supposed to use a variable that I assign within an if statement after the if statement is exited? You know, sometimes these little things just leave me in utter unbelief and shock that Kaseya designs something so pathetically screwed up.

    One of the most basic concepts and they can't get that right?

    [edited by: Appleoddity at 7:59 PM (GMT -7) on 8-4-2011] Edited
  • From the help file:

    Note: Procedures variables cannot be referenced outside of the procedure or nested procedures that use them except for GLOBAL variables. A procedure variable is only visible to the section of the procedure it was created in and any child procedures. Once a procedure leaves the THEN clause or ELSE clause the variable was created in, the variable is out of scope and no longer valid. Use GLOBAL Variables, described below, to maintain visibility of a variable after leaving the THEN clause or ELSE clause the variable was created in.


    Wow.  I can understand between parent and child procedures.  But, never in my life have I seen a programmimg or scripting system behave like this after an if then else statement.  Unbelievable.

  • Its been like that for over a year, you are just behind the times Stick out tongue

    About 2 years ago we didn't even have nested if statements and we had to daisy chain these single if statement scripts together to get the same result and the only way to pass variables from one chain to another it to write the to a text file or the registry and then read them back in.

    Keep in mind that Kaseya's scripts where never really intended for complex scripting and because of the demand for complexity they are planning to move to Lua  

    [edited by: HardKnoX at 8:14 PM (GMT -7) on 8-4-2011] typo
  • I can appreciate that.  I have taken to writing vbScript to accomplish my tasks, and using Kaseya to transfer it to the system, execute it, and monitor it.