In order to execute the script automatically when Agisoft Metashape Professional instance is run you need to place Python script to the following folder:
on Windows:
C:/Users/<username>/AppData/Local/Agisoft/Metashape Pro/scripts/
on Linux:
/home/<username>/.local/share/Agisoft/Metashape Pro/scripts/
on macOS:
/Users/<username>/Library/Application Support/Agisoft/Metashape Pro/scripts/
on any OS (for all users):
<installation folder>/scripts/
Usually, such autorun scripts are useful for adding custom menu options to call the custom processing operations directly from the application GUI instead of using Run Script dialog each time.