2

I've tried multiple ways but none work. A few AppleScripts and even some bash script somebody made. Which essentially just executes a different AppleScript afaik.

Some of the commands I have tried:

osascript -e 'tell application "System Events" to make new login item at end with properties {path:"/Applications/AppName.app", name:"App Name", hidden:true}'

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

defaults write loginwindow AutoLaunchedApplicationDictionary -array-add '{ "Name" = "AppName" ; "Path" = "/Applications/AppName.app"; "Hide" = 0; }'

defaults write loginwindow AutoLaunchedApplicationDictionary -array-add '<dict><key>Hide</key><false/><key>Path</key><string>/path/to/item</string></dict>'
  • Posting a few samples of the AppleScript and bash script code which doesn't work can help determine what may be wrong. – IconDaemon Nov 26 '19 at 14:33
  • Done. Edited the post. – undefinedChar Nov 26 '19 at 14:41
0

Try enabling AEServer and/or Script Editor in System Preferences > Security & Privacy > Accessibility. Occasionally I've had to quit and relaunch System Preferences for new login items added via AppleScript to appear.

After doing this I was able to add login items via AppleScript. Confusingly, after I disabled Accessibility access for AEServer and Script Editor I was still able to add login items via AppleScript.

| improve this answer | |
  • I just tested this in macOS Catalina 10.15.4 and it does not work! – user3439894 Apr 12 at 4:48
  • Sorry to hear that 😕 I'm also on 10.15.4 and it worked for me. Did you try restarting System Preferences? Also, from which app are you running the script? – ACB Apr 12 at 5:31
  • Yes I restarted System Preferences. Tried in both Script Editor and Terminal, both have permission as well as AEServer. – user3439894 Apr 12 at 5:35
  • A wild stab in the dark: Did you grant them permission in an earlier version of MacOS? If so, try disabling and re-enabling. Other than that, I would restart your computer and hope for the best. Sorry I can't be more helpful. – ACB Apr 12 at 6:30
  • This is on a clean built system running macOS Catalina 10.15.4 and also has been rebooted before and after adding AEServer and it didn't work. – user3439894 Apr 12 at 6:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .