Kaseya Community

Is software installed

This question is not answered

 Hi all,

Can anyone tell me why this is not working ?

I need a way to check if a software is installed correctly and I would like to check multiple things before the script should inform the user if the installation was successful or failed. I would like to test if for example a registry key exist AND if that exist if a file exist in a specific folder AND if that exist perhaps check if the user is logged on AND if so then a popup should show the user if the installation has failed or was successful.

The attached does not work as it seems like it only check on line 10 and 11. If I on the other hand only set one parameter to check for for example if testFile and delete line 8 and 9, then it works just fine ?

Can anyone please assist and inform me what is wrong ?

On a side node is there anyway to force the procedure to show a fail status in the console if for example one of the above things I would like to check for fail to exist ?



Picture attached.
[edited by: henrik.k at 2:19 AM (GMT -7) on Oct 20, 2020]
All Replies
  • Your logic seems flawed - you want to test multiple things, but if any item tests OK, you set the value to Pass. You need every test to pass to assume the software is fully installed. Try reversing this - assume success by setting the initial value to TRUE. Then, if any test fails, it sets the value to FALSE. Now, when you test, if all tests have passed, it will be TRUE, but if any test fails, it will be set to false.

    To force the procedure to report a failure, simply perform an invalid task with Halt on Fail set. Be sure you write and perform any cleanup first!

    Glenn

  • Glenn is right, in that his method uses OR logic... you'r approach can work too, but it's uses AND logic.  So, think of it like this...

    IF BOTH tests need to be TRUE, then it is an AND

    But IF either being FALSE causes the test to be FALSE, it becomes an OR.

    To do an OR, you set it to TRUE and let either TEST1 set to FALSE OR TEST2 set to FALSE.

    If you want to write it assuming FALSE, as an AND... then you need to nest the second test by Indenting it... so you do TEST1, if it passes, TEST2 is on the THEN... so TEST2 only happens if TEST1 passes.  If either fails, then its FALSE.

  • You need to nest your if statements, and have else statements to handle if any of them are not met:



    updated screenclip
    [edited by: Trevor@Correct at 3:37 PM (GMT -7) on Oct 20, 2020]
  • There is another way that I also do this, that does not nest the IF statements.

    It tests multiple areas and appends any failure flags into a temp file, then at the end it reads it back and confirms it does not contain the word "Fail".

    I find this approach easier when there are many tests that have to pass.

  • Deep nested If statements can be problematic to write and troubleshoot. We have some pretty complex tools and I don't think we nest anything more than 2 levels.

    Skip the external file and just write to a global:STATUS variable - either Phase or FAIL. Same end result but no File IO or trash left behind.

    getVariable("constant value", "#global:STATUS phase|FAIL", "global:STATUS")

    You can write that line to the procedure log at the end and know where it failed, or write it and force a failure.



    add info
    [edited by: gbarnas at 3:54 PM (GMT -7) on Oct 20, 2020]