How to edit login items via Terminal

Discussion in 'macOS' started by CharlieJames91, Sep 1, 2016.

  1. CharlieJames91 macrumors newbie

    CharlieJames91

    Joined:
    Jun 3, 2016
    #1
    Hi.

    Is there an easy terminal command to place applications in the users login items specifically for 10.10/10.11

    I did have a post on this yesterday but it was mis-understood, all I need to know ia if there is an easy terminal command to place apps in the login items.

    I'm not great with isoscripting etc so was hoping there is an easy 1 line command to do this.

    Thanks
     
  2. chown33, Sep 1, 2016
    Last edited: Sep 1, 2016

    chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    See here:
    https://gist.github.com/kaloprominat/6111584

    The command lines given there are shell commands. The 'osascript' command runs AppleScript scripts. The best way I know of to access login items is via AppleScript.

    To change the examples, you'll need to know the Posix pathname of the application.

    I don't understand what you mean by "isoscripting". Maybe you meant something about the 'osascript' command. Accuracy is important in programming.

    EDIT:
    Sorry, the URL didn't paste correctly the first time. Updated with link.
     
  3. CharlieJames91 thread starter macrumors newbie

    CharlieJames91

    Joined:
    Jun 3, 2016
    #3

    Thank you. I have tried the above link but not entirely sure if I am doing something incorrectly - see bellow:

    osascript -e 'tell application "System Events" to make login item at end with properties {name: "Microsoft Lync",path:"/Applications/Microsoft Lync.app", hidden:false}'

    36:153: execution error: System Events got an error: AppleEvent timed out. (-1712)


    I was rushing on my mobile device when I created this thread but I agree, I should have defined this more accurately. I am a beginner - and hopefully, will not be making these mistakes for much longer.

    Thank you
     
  4. chown33, Sep 2, 2016
    Last edited: Sep 2, 2016

    chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    First, read about using CODE tags in posts:
    http://forums.macrumors.com/threads/posting-code-please-use-the-code-tags.747660/


    Test #1:

    Paste the following commands into Terminal. Post the complete output in CODE tags.
    Code:
    osascript -e 'tell application "System Events" to get count of login items'
    
    osascript -e 'tell application "System Events" to get the name of every login item'
    

    Test #2:

    Paste the following command into Terminal. Post the complete output in CODE tags.
    Code:
    defaults read loginwindow AutoLaunchedApplicationDictionary
    
     
  5. CharlieJames91 thread starter macrumors newbie

    CharlieJames91

    Joined:
    Jun 3, 2016
    #5
    Thanks for the heads up. the Apple script actually does work, just not with elevated privileges. In fute I will use the CODE tags, also.

    Thank you.
     

Share This Page