The related page "Run a user language program" (see link below) explains a convenient way to run User Language Programs from the Schematic Automate or PCB Automation panel. You can also use an editor window's command line to execute a ULP with the RUN command:
RUN sample.ulp
A ULP can return information on whether it has run successfully or not. You can use the exit() function to terminate the program and set the return value.
A return value of 0 means the ULP has ended "normally" (i.e. successfully), while any other value is considered as an abnormal program termination.
The default return value of any ULP is 0.
When the RUN command is executed as part of a script file, the script is terminated if the ULP has exited with a return value other than 0.
A special variant of the exit() function can be used to send a command to the editor window as a result of the ULP.