Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6666527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:50:16+00:00 2026-05-26T02:50:16+00:00

I need a way to add an application to the Login Items from a

  • 0

I need a way to add an application to the Login Items from a postflight script which is run as part of my installer. It needs to work on 10.5+. Preferably, it would work in a bash script. My application already requires administrative rights.

The approach I found here: Mac OS Login Items with Arguments? seemed to be on the right track (included below)… but didn’t work when I tried it on command line and I’m not sure how to make it install for All Users or if I need to add logic to check if it’s already added to startup items before calling this code.

#!/bin/bash
/usr/bin/osascript -e "tell application \"System Events\" to make new login item with properties { path: \"$1\", hidden:false } at end"

I suspect I could also do something with a launchd. But, I’m not sure which approach is the best practice for compatibility across versions.

NOTE: I do NOT want to add it using some objective-c code inside my app. I need the installer to add it. Currently, what I do is start the application after install which then Adds it to Login Items in code using the LSSharedFileListRef… Example of that approach can be found here: How do you make your App open at login?. The reason this is not ok is I need to make my application install with Apple Remote Desktop via command line, when on the login screen. So, the application needs to not start automatically after install.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:50:17+00:00Added an answer on May 26, 2026 at 2:50 am

    Here’s the options I investigated and experimented with:

    Option 1: Use Login Items

    This is the method I used. It’s very easy to do from a bash file by adding the following line to your postflight.

    defaults write /Library/Preferences/loginwindow AutoLaunchedApplicationDictionary -array-add '{Path="/Applications/Your Application.app";}'
    

    Note: You don’t even have to worry about adding duplicates if you reinstall the application. The loginwindow process removes duplicates when it reads them.

    I tested this on 10.5, 10.6, and 10.7
    @noa says this doesn’t work on mountain lion (10.8), Haven’t personally confirmed.

    Option 2: LaunchAgent

    The unique ramifications of using a Launch Agent are:

    1. Your application doesn’t appear in the Login Items list, so the
      user really has to know what they’re doing to get rid of it
    2. The user cannot end your applications process without running:
      launchctl unload /Library/LaunchAgents/com.your.package.plist

    Here’s some code you could use to create the launch agent in your bash file:

    cat > /Library/LaunchAgents/com.your.application.agent.plist << EOT
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.your.application.agent</string>
        <key>ProgramArguments</key>
        <array>
            <string>/Applications/Your Application.app/Contents/MacOS/Your Application</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
    </dict>
    </plist>
    EOT
    

    Option 3: Compile Obj-c code to a binary

    I never actually finished this approach. Apparently, this is the approach that Novell takes. Essentially you’d make a foundation application that calls the libraries referenced from this solution:
    How do you make your App open at login?

    Other

    Didn’t try this but according to this post if you want it to work on tiger you need to use AppleScript..? I can’t confirm or deny that but thought this link might be relevant.
    Editing Mac OS X login items in Objective-C through AppleScript

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some way to add a class attribute to the output of the
I need a way to build C++ code from UML diagrams and vice versa.
I am writing an application where you need to show login screen modally and
I'm building an application where users can add, edit and delete users from the
I have a CakePHP 1.3 application that has a login system, which works well.
Need a way to allow sorting except for last item with in a list.
I need a way to easily export and then import data in a MySQL
I need a way to recursively delete a folder and its children. Is there
I need a way to update the month value on a dateTime field in
I need a way to bind POJO objects to an external entity, that could

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.