I have an Application created with Automator. Since the application starts a service in the background, I'd like to keep the application open even after the end of the workflow is reached. When the user quits the application, I'd like to execute a command to stop the service. How can I achieve the above?
I don't know of a way to make a "stay open" Automator app, but you could make a simple "stay open" AppleScript app that can launch an Automator app to start your service, then, when the user quits the AppleScript app, it can launch a 2nd Automator app to stop the service.
Such an AppleScript would look something like this:
You could then replace "1st Automator App" with the name of the Automator app that will start the service, and replace "2nd Automator App" with the name of the Automator app that will stop the service.
You would then save the AppleScript as an application with the "stay open" option checked.
Depending on what else your Automator app needs to do, it may be possible to skip Automator altogether and start and stop the service directly in AppleScript.