Programmatically run at startup on Mac OS X?

前端 未结 4 1833
悲哀的现实
悲哀的现实 2020-12-07 21:09

How do I programmatically set an application bundle on Mac OS X to run when the user logs in?

Basically, the equivalent of the HKCU\\Software\\Microsoft\\Windo

4条回答
  •  粉色の甜心
    2020-12-07 22:05

    You can add the application to the user's "Login Items" (under System Preferences=>Accounts=[user]) or you can add a launchd agent to the user's ~/Library/LaunchAgents folder (see man launchd.plist). Use ~/Library/LaunchDaemons/ if your app has no user-facing UI. As others point out, launchd gives you a lot of control over when the app starts, what happens if the app quits or crashes, etc. and is most appropriate for "daemon" style apps (with our without UI).

    The first option (Login Items) can be manipulated programmatically (link from Gordon).

提交回复
热议问题