在Mac OS X上启动时以编程方式运行? [英] Programmatically run at startup on Mac OS X?

查看:96
本文介绍了在Mac OS X上启动时以编程方式运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在用户登录时以编程方式在Mac OS X上设置应用程序捆绑包以运行?

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

基本上,等效于Windows中的HKCU\Software\Microsoft\Windows\CurrentVersion\Run注册表项.

Basically, the equivalent of the HKCU\Software\Microsoft\Windows\CurrentVersion\Run registry key in Windows.

推荐答案

您可以将应用程序添加到用户的登录项"(在系统偏好设置" =>帐户= [用户]"下),也可以添加启动代理到用户的~/Library/LaunchAgents文件夹(请参阅man launchd.plist).如果您的应用程序没有面向用户的UI,请使用~/Library/LaunchDaemons/.正如其他人指出的那样,launchd可让您对应用程序的启动时间,应用程序退出或崩溃时发生的情况等进行大量控制,并且最适合守护程序"样式的应用程序(使用我们的不带UI).

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

可以选择第一个选项(登录项) Gordon 链接).

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

这篇关于在Mac OS X上启动时以编程方式运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆