The function is called in scripts and services when the Start event occurs. The function is intended for one-time execution of actions implemented in a program. There are two function types.
The version that returns the result
The value of int type displayed in the Journal tab.
The entry "script script_name removed (result code N)" is created in the terminal journal after a script execution is complete. Here N is a value returned by the OnStart() function.
The entry "service service_name stopped (result code N)" is created in the terminal journal after a service execution is complete. Here N is a value returned by the OnStart() function.
The OnStart() call that returns the execution result is recommended for use since it not only allows for a script or service execution, but also returns an error code or other useful data to analyze the program execution result.
The version without a result return is left only for compatibility with old codes. It is not recommended for use
OnStart() is the only function for handling events in scripts and services. No other events are sent to these programs. In turn, the Start event is not passed to EAs and custom indicators.