Question

Is there any way to automatically launch an application on USB attach or CD insert on Mac OS X? it's easy on Windows, but I found that AutoRun.Inf does not work on the Mac at all.

Was it helpful?

Solution

You can't. Autostarting applications is impossible under Mac OS X.

The next-best thing, opening the CD folder and showing the installer icon, can be done by using http://autoopen.nibfile.com/ to make a .dmg which can then be burnt to a CD.

OTHER TIPS

Don't know why you were voted down - this is a common question for Windows programmers looking at Macs.

Basically, auto-run is considered a security problem and so is not supported in OSX. Sophie (formerly known as Ben) Alpert's answer is also a bit overkill. Most installers for OSX simply open up a folder to show the application and, possibly, a readme. Installing is done by dragging the app to your Applications folder.

For other kinds of apps on CDs (say, a slide show or something like that), the developer generally uses hidden folders to hide support data to ensure that the only thing the user will see when they open the CD is the single icon they're supposed to double click to start the app.

If you are looking for something for just yourself, you could write a small mac app that runs in the background and watches for a particular USB device (by id) to be attached and then run the program. Ideally a small XML plist could be used to map device IDs to the correct program to run. The XCode SDK has sample code that monitors for device additional and removal to get you started.

It is possible to install a background service that monitors whenever a USB device is plugged in and then launches an App. Google's "Android File Transfer Agent" is such a service that is running in the background and launches "Android File Transfer" whenever you plug in an Android device.

I agree with JavaCoderEx. I would crontab a task that looks for /Volumes/*/autorun.sh, then runs it once. Maybe touch a file in /tmp/ so you know its already been run, then remove it if the volume disappears.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top