0

I am running MacOS Big Sur. I installed some apps downloaded online. I found out many apps were started automatically at startup.

By googling and examining my system, I figured out they were started from the file backgrounditems.btm which is located at ~/Library/Application Support/com.apple.backgroundtaskmanagementagent/. The file stores Login Items.

By running a python script downloaded online, I can see many Login Items registerd in the file backgrounditems.btm and they are NOT shown in System Preferences > Users > myuser > Login Iterms.

I tried the command osascript -e 'tell application "System Events" to delete login item "name"' to delete the hidden login iterm, but failed with error message "36:73: execution error: System Events got an error: Can’t get login item "myapp.app". (-1728)"

These hidden login iterms are also NOT shown when I use the command osascript -e 'tell application "System Events" to get the name of every login item'.

So my question is how to remove those unwanted login iterms to stop them autostart at my login. Command Line Way is prefered. I think some GUI apps such as ccleaner may do the job, but I don't want to install some GUI apps which may be autostarted themselves. Basically, I don't want to install an autostart iterm to remove autostart items.

Thanks a lot.

Update

I figured out the file is in a binary plist format.

Then I tried two tools.

One is the default cml tool plutil. Another one is a thirdy party tool ProperTree. Both can convert and open the binary plist as XML plain plist. But even with a plain plist format, it's kinda hard to understand it. The important sections are still coded in base64 format in xml.

I can decode base64 with many tools, but I still feel it's kinda too much work for this purpose. Do anyone know any easier way to remove hidden login iterms from the file? Thanks.

3
  • 1
    Only LoginItems that were entered in the system settings for the respective user are written in here. /System/Volumes/Data/Users/$(whoami)/Library/Application Support/com.apple.backgroundtaskmanagementagent/backgrounditems.btm I am currently not aware of any way that LoginItems can be found. Because LoginItems can also be stored within an application package. They do not necessarily have to be stored in the system settings. Apps like EtreCheck check the /Applications directory for LoginItems. I don't think launchd is responsible for that
    – BabyBoy
    Apr 9, 2021 at 7:54
  • 1
    Have you checkes the Launch Daemons and Launch Agents at ~/Library/LaunchAgents, /Library/LaunchDaemons, and /Library/LaunchAgents. These store plists, each with instructions for launching an application/process at login. They are generally not listed in login items in system preferences. Jan 4, 2022 at 9:18
  • I deleted iMazing but it still showed in "Allow in the Background". Searching /Library/LaunchDaemons and /Library/LaunchAgents found nothing. Deleted the annoyingly persistent iMazing launch item in ~/Library/LaunchAgents with rm com.DigiDNA.iMazing2Mac.Mini.plist. Re-opened System Settings… and checked Login Items, it was gone. For (AppCleaner) I right-clicked the app, "Show Package Contents" found Contents/Library /LoginItems/AppCleaner SmartDelete folder and deleted it manually. and it was gone too. Seems Ventura polls these locations without needing to restart. Dec 12, 2023 at 17:15

2 Answers 2

0

Parsing plists

You can use the command:

faq -f plist -o json '.["$objects"][] | objects | select(.hidden == true)' ~/Library/Application\ Support/com.apple.backgroundtaskmanagementagent/backgrounditems.btm | less

This will list entries in backgrounditems.btm that are hidden. It uses faq which works like jq but with many different file formats supported for input, including .plists.

You could use faq to write a query for that excludes only these entries, or use vim-plist to open the file in vim and remove whatever you like.

You might want to check the following if you haven't first though. These seem to be the more likely culprits for your issue...

LaunchDaemons & LaunchAgents

Have you checked the Launch Daemons and Launch Agents at ~/Library/LaunchAgents, /Library/LaunchDaemons, and /Library/LaunchAgents? These store plists, each with instructions for launching an application/process at login. They are generally not listed in login items in system preferences.

-1

I don't think it is necessary to remove them using the commands. You can do it from settings.

Open System Preferences and click on Users & Groups, then click the Login Items >tab. You’ll see a list of apps (and even files and folders) that open every time you log in. - Macworld

2
  • Thanks for your reply. But I think you didn't really read my question... To avoid wrong answer, in the third paragraph of the question, I have mentioned that they are NOT in the System Preferences > ... > Login Iterms. And that's why I always use the word "hidden" in the question. Cheers.
    – sgon00
    Apr 9, 2021 at 5:33
  • Oh yeah you're right ha. I would use AppCleaner although I know you would rather do it from the command line. Apr 9, 2021 at 21:51

You must log in to answer this question.

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