Startup Application via terminal

Discussion in 'OS X El Capitan (10.11)' started by CharlieJames91, Aug 31, 2016.

  1. CharlieJames91 macrumors newbie

    CharlieJames91

    Joined:
    Jun 3, 2016
    #1
    Hi everyone.

    Does anyone know how to startup applications via terminal upon startup/login? The machines ae all on 10.11.

    Please help.

    Thanks,
     
  2. dogslobber macrumors 68020

    dogslobber

    Joined:
    Oct 19, 2014
    Location:
    Apple Campus, Cupertino CA
    #2
    Open /Applications/Safari.app

    That should do it.
     
  3. keysofanxiety macrumors 604

    keysofanxiety

    Joined:
    Nov 23, 2011
    #3
    Not sure I quite understand the question, but I'll try to help.

    You can open applications by typing open -a "xxxx"; for instance, open -a "App Store" will open the App Store if it's in the Applications folder. The '-a' modifier isn't necessary, but there are a lot of other options you can open an app with if you're interested.

    If it's an app outside of the Applications folder, you can use open -a FILEPATH. Filepath being, for example, open -a Users/Username/Documents/App-You-Want-To-Open.app

    If it's a file you just want to open, you can just say open FILEPATH. So if it's a document, open Users/Username/Documents/Document-You-Want-To-Open.docx

    However there's a much easier way to open apps on startup. Just open the app as you normally would. You'll see it in the Dock at the bottom. Right-click that and select 'Options>Open at Login'. Then that app will always start as soon as you open the computer.

    Could you outline exactly what you're trying to do (i.e., the scenario you need the fix for)? This might help us a little more. :)
     
  4. CharlieJames91 thread starter macrumors newbie

    CharlieJames91

    Joined:
    Jun 3, 2016
    #4
    Hi,


    Essentially I just need a script that will add an application to the startup applications via system preferences. Manually adding the application is not an option as we need to push this out on to a large number of machines. So ideally if we could just push out a script that will add this specific application to login items that would be PERFECT.


    Thank you for your reply.
    --- Post Merged, Aug 31, 2016 ---
    #4
    Hi,


    Essentially I just need a script that will add an application to the startup applications via system preferences. Manually adding the application is not an option as we need to push this out on to a large number of machines. So ideally if we could just push out a script that will add this specific application to login items that would be PERFECT.


    Thank you for your reply.
     
  5. chrfr macrumors 603

    Joined:
    Jul 11, 2009
    #5
    Configuration profiles are a good way to do this. You can also create LaunchAgents which can do this too.
     
  6. DeltaMac macrumors 604

    DeltaMac

    Joined:
    Jul 30, 2003
    Location:
    Delaware
    #6
    Does that app that needs to be always open, have a name?
    It already has a Dock icon, correct?

    What is the result if one of those users decides to just quit that application, or the app quits when you close the app's window (some apps do that)?
    If you quit the application, then you have to do something to re-launch the app (Apps don't stay open forever, just because they launch as a startup item. If you decide to Quit the app, it quits… This is not Windows :D )

    Maybe you should ALSO have a script that continually checks for that app, and re-launches it automatically, if closed?
     
  7. CharlieJames91 thread starter macrumors newbie

    CharlieJames91

    Joined:
    Jun 3, 2016
    #7

    Hi there, it is not a problem if the user quits the app, we just want the app to start at startup - that's all.

    Thank you
    --- Post Merged, Aug 31, 2016 ---
    The application in question is Lync. nothing extra is needed i.e dock icon etc, just simply needs to be added to the login items on system pref.

    Thank you
     
  8. KALLT macrumors 601

    Joined:
    Sep 23, 2008
    #8
    Login items are not persistent, your users can remove these. If you want to enforce this behaviour, then you should use system-wide launch agents to get the behaviour you want, but they are obviously not shown in System Preferences. It is possible to add login items using AppleScript and the osascript command-line utility. What is it that you want to achieve exactly?
     
  9. chrfr macrumors 603

    Joined:
    Jul 11, 2009
    #9
    Again, Configuration profiles are the way to do this, and allow a lot of other management options that might be valuable.
     
  10. grahamperrin macrumors 601

    grahamperrin

    Joined:
    Jun 8, 2007
    #10
    That could be troublesome.

    Recommended reading: Creating Launch Daemons and Agents
     
  11. CharlieJames91 thread starter macrumors newbie

    CharlieJames91

    Joined:
    Jun 3, 2016
    #11
    Hi there, the users can remove this start up application if they wish, it's more so to just make the user aware that the application is there, if we get the application to start up automatically when they sign in then we can let their curiosity go from there, and they can remove if they wish. I have been unable to find any easy way around this on el capitan. I know back a couple os's like 10.4 there was a folder in the user library that could easily be edited but not so much anymore. I've tried using opensnooping to monitor the changes when I manually add an application to login items but not much luck so far
    --- Post Merged, Aug 31, 2016 ---
    I will look into configuration profiles, thanks. Our users are already setup etc via AD which is why I just want to to push out a script to add an app to their login items
     
  12. chrfr macrumors 603

    Joined:
    Jul 11, 2009
    #12
    Do you have a deployment infrastructure in place? If so, what is it?
     

Share This Page