I need to run my application on startup. So when the user boot up his Mac and is about to see his desktop, my application needs to launch. I set my app to run as launchd. I am using the QueuedDirectories flag in the plist of the launchd process. So if I place a file it launches up automatically. I have looked at the question – How do I launch an application on system startup? (Mac OSX, Cocoa). The suggested answer is to use launchd.
I have two questions –
-
In Macs where more than one accounts are present, the application does not launch for the other user(who has not installed it). In Windows you can install program for everyone. Is a similar thing possible on Mac. If so, I can use the Queued directory approach with launchd.
-
Is launchd the right way to start an application at startup/login in Lion as well. Or has Apple added any new feature with Lion which will allow this to be done in a smarter way. I looked up and everything does seem to point towards launchd.
I am targeting Snow leopard and Lion.
Yes, you should be using launchd. Have a look at my answer to this question.
Basically, you need to install your launchd configuration file in the root
/Library/LaunchAgents/folder rather than an individual user’s~/Library/LaunchAgents/folder. That way, it will launch an instance for each user that logs in.