简体   繁体   中英

Add Login Item from Command Line Tool on OSX

I just got an assignment where I need to add the running program to the login items for all users on OSX >= 10.5. The program is a command line tool and I am developing it in xcode. I found some ways to add login items, but they either run from a shell or use the cocoa framework.

How can I do this?

Here's an example of how I've done this from the command line:

defaults write loginwindow AutoLaunchedApplicationDictionary -array-add '{Path="/Applications/Utilities/Terminal.app";}'

To execute a command like that from Obj-C, see this thread:

Cocoa/ Objective-C Shell Command Line Execution

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM