Run script on application launch

Hi... I am tearing my hair out trying to get a script to run when I open an application. Yes, I know I could write a script that I use to then launch the application in question after doing the operation in question, but that is a kludge... I simply want to check for a mounted volume when itunes launches and then mount it if it is not mounted.

FOlder actions do not seem to treat applications as folders even though they are... launchd cannot watch for an application launch and run a script... and the simplest thing of all... itunes cannot manage a scripts library or be told to run something when a certain event happens.

arg.

any ideas?

12 inch iBook G4 800

Posted on Dec 28, 2006 5:48 PM

Reply
1 reply

Dec 30, 2006 2:44 PM in response to Modmans2ndcoming

The 'right' way of doing this is for the application to be 'attachable' - a standard method supported by the OS where applications can automatically call scripts defined by the user at specific events (such as launch, quit, etc.).

Unfortunately, few applications support this. Pretty much the only workaround is what you describe - a script that performs the checks/actions you want, then launches the application. Of course, this requires you then use that script to launch the app rather than double-clicking the application itself, so it's far from perfect.

There is one other option that might work, and that's automount.

When configured, you map a directory on disk to a server volume. Whenever any application tries to access that directory, the OS automatically mounts the relevant server volume without any user action. This is how server-based home directories work - the client automounts the server as soon as the user logs in.
This might solve your problem in this case, but it wouldn't work for other cases that have other actions you want to perform.

This page has a walkthrough of setting up an automount that you might be able to tweak.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Run script on application launch

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.