Your problem is likely to be the value being returned in @ERROR.

What is happening is that the API is returning either a negative value, or a very large unsigned integer which appears to be negative when stored in a signed data type.

If you pass a negative value to "Exit" it will cause the missing script error - KiXtart has done this for as long as I can remember.

You can create a very simple test script with "Exit -1234" which will exhibit the same error.

If you display the value of @ERROR you will probably find it is negative.

The solution is to cast @ERROR to a non-negative integer if you want to use it when exiting the script.

If you use Exit with a negative value internally in a script there is no problem and the value is preserved. It is only a problem when exiting KiXtart.