How do I automatically run an application on USB attach or CD insert on Mac OS X?

0 votes
asked Jan 4, 2009 by yigang-wu

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.

4 Answers

0 votes
answered Jan 4, 2009 by sophie-alpert

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 to make a .dmg which can then be burnt to a CD.

0 votes
answered Jan 5, 2009 by mike-heinz

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. 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.

0 votes
answered Jan 27, 2011 by javacoderex

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.

0 votes
answered Jan 16, 2014 by eduard-feicho

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.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter