How can I clean Unknown item of kind Unknown from my Account startup items system preference pane?

I was running some beta apps that try and insert themselves as log in items and now need to clean up the mess they left.

I'm speculating something went wrong while trying to follow this and this solutions in order to add 'launch at login' functionality to my app.

Now I have many unknown items in there which are not removable. I was able to retrieve the 20 items only by running this code:

let loginItems: NSArray = LSSharedFileListCopySnapshot(loginItemsRef, nil).takeRetainedValue() as NSArray
  • However the LSSharedFileListItemRemove method is deprecated and I can't remove them programmatically on High Sierra or later.
  • Furthermore, now when I click on hide in any of unknown login items, I get another unknown entry below duplicated. I had only one, but when clicked many times(not believing that such a bug can be in OS X) on hide/unhide I got 20 of them. This means attempts to clean one item grows more from the UI.

Checked with no luck:

/Library/LaunchDaemons/
/Library/LaunchAgents/
~/Library/LaunchAgents
/Library/StartupItems
...loginitems.plist
...loginwindow.plist

enter image description here

Is there a way to nuke all the items in this list to get a clean start?


This appears to be a bug in OS X High Sierra (it may affect other versions too) and has been bugging the crap out of me for the past few weeks. I finally managed to find a solution, thanks to a post I made on this Github issue. Try this solution.

Basically you will want to remove the file $HOME/Library/Application Support/com.apple.backgroundtaskmanagementagent/backgrounditems.btm. Then reboot.

Note that that this will remove all Login Items you currently have set up so be sure and make a note of all of the apps, volumes, etc. you currently have set to auto-launch at startup, because you will have to re-set them up. But this definitely got rid of all the "Unknown" items for me.

The other alternative is to set up a new user folder and migrate in your other files, but having a backup and erase install / migrating in from a backup is a great solution as well.