Mac OS X: login之前/之后启动程序的方法

下面是看到的总结OS X里面如何在用户登录前自动运行一个程序的方法:

1) GUI applications launched by putting them in /Library/Preferences/loginwindow.plist -> AutoLaunchedApplicationDictionary

2) A single Non-GUI executable launched using the loginhook

3) A single Non-GUI executable launched using the MCX loginhook system (can be run instead of or in addition to #2)

- note: the next two items have corresponding structures in /System/Library, and possibly in ~/Library

4) Items (possibly GUI) launched with a plist in /Library/LaunchAgents that don't have a LimitLoadToSessionType of Loginwindow

5) Non-GUI items launched out of /Library/LaunchDaemons

- note: the next two items used to be able to have GUI's, but the 10.5 loginwindow environment now does not allow GUIs unless a number of hoops are jumped, neither of these qualifies (without some serious work-arounds)

6) Non-GUI applications launched out of /Library/StartupItems or /System/Library/StartupItems

7) Non-GUI applications launched out of /etc/mach_init.d, /etc/mach_init_per_login_session.d, or /etc/mach_init_per_user.d

8) Items launched out of /etc/rc.* (it is possible to launch GUI applications out of here in some circumstances)

9) MCX launched GUI items


下面是Apple官方的关于pre-login launch的举例文章:PreLoginAgents:http://developer.apple.com/samplecode/PreLoginAgents/index.html


目前看到的Apple官方关于Daemons and agents的比较全面的文章:

Technical Note TN2083

Daemons and agents

http://developer.apple.com/technotes/tn2005/tn2083.html#SECSYSTEMLOGINITEM

还有这个是关于如何在用户登录的时候启动程序的:

Technical Note TN2228
Running At Login

http://developer.apple.com/technotes/tn2008/tn2228.html


你可能感兴趣的:(Mac OS X)