Midwire

Ruby, Elixir, Macintosh and Other Technical Maunder.

Prevent MacOS Applications From Adding Launch Agents

Many OSX users don’t realize that applications can install their own launch agents1 without you ever knowing it. I found this out because I use some software called Drive Genius to monitor my hard drives and their health, which watches the launch agent folders for new files or changes to existing files. When it detects any changes it pops up a notification like this:

You can find a similar, free, offering here called CIRCL automatic launch object detection: http://www.circl.lu/pub/tr-08/

When I catch an application doing that I use AppleScript to write a launcher which will launch it and then delete any launch agent that it drops.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Launch Amazon Music and remove it's attempt to force itself into your login items

tell application "Amazon Music" to activate

tell application "System Events"
  set startupItems to (name of every login item)
  repeat with i from 1 to count of startupItems
    if startupItems's item i is equal to "Amazon Music" then
      delete login item "Amazon Music"
    end if
  end repeat
end tell

delay 3

tell application "Finder"
  delete (every item of folder "LaunchAgents" of folder "Library" of folder "cblackburn" of folder "Users" of startup disk whose name begins with "com.amazon.music")
end tell

do shell script "/bin/launchctl remove -w com.amazon.com"

Just modify it to your needs and it should help keep unwanted launch agents at bay.


  1. A launch agent is similar to a cron job, but OSX specific.

Comments