Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

developer.in

macrumors newbie
Original poster
Nov 5, 2008
8
0
Hi

In my mac application I want to give the user an option of starting the app on startup in application preferences.
How can I add or remove my application to startup programs programatically?
I am using Objective-C as the programming language.

Thanks
 

yellow

Moderator emeritus
Oct 21, 2003
16,018
6
Portland, OR
Not sure about programmatically, but here's what I use for AD attached Macs that won't open Login Items appropriately on cached credentials. Maybe it'll lead you in the right direction:

Make sure you have the latest version of Property List Editor installed (it's much easier than trying to accomplish this via command line, which I might detail here anyway). Be logged in as the user you want to fix, or as root, since you won't have the ability to read/write the file as anyone else.

Open the editor, and point it at /Users/username/Library/Preferences/loginwindow.plist
There should be an "AutoLaunchedApplicationDictionary" entry already. If not, create one (as an array).
Add a new child and it'll automatically be a number, make it Dictionary and open the twisty.
Add a new child to that number, name it "Hide", make it Boolean, and set to no (or yes, if you want it hidden).
Add a new sibling, name it Path, make it a String, and put in the full path to the object you want to start up at login. In comparison to other entries, you might see "AliasData". Don't worry about that, it will be created automatically.
Save and logout.
Log back in. The login item should fire correctly.
 

developer.in

macrumors newbie
Original poster
Nov 5, 2008
8
0
Not sure about programmatically, but here's what I use for AD attached Macs that won't open Login Items appropriately on cached credentials. Maybe it'll lead you in the right direction:

Thanks. That did help. But is there any way I can open it as a source code file like we open a normal info.plist? Shows some garbled values when I tried. I wanted to see the the format.
 

yellow

Moderator emeritus
Oct 21, 2003
16,018
6
Portland, OR
Ah, plists were converted to binary files in Tiger (I think), where they were flat text before that.

plutil can be used to convert from bin/xml.
 

satyam90

macrumors regular
Jul 30, 2007
242
0
Bangalore, India
I tried a lot with UKLoginRegistry on Mac Tiger. But didn't work. The same thing if I debug line by line it is working. When I run as an application its not working.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.