1

My app(my.app) will add an plist file(com.agent.plist) to /Library/LaunchAgents, and it will trigger another app(agent.app) when my.app is runatload. I know that the agent.app will be loaded as non-root permission because it is in /Library/LaunchAgents. Next time, in the uninstall script of my.app, i want to user launchtl remove com.agent.plist to kill the agent.app process. But the uninstall script is triggerred by root permission, so it seems like using sudo launchtl remove com.agent.plist, this doesn't work becuase agent.app is not owned by root.

So anyone can tell me how to implement this?

jimwan
  • 1,086
  • 2
  • 24
  • 39

1 Answers1

0

It is…challenging. This is the inverse version of How can you start a LaunchAgent for the first time without rebooting, when your code runs as a LaunchDaemon?.

You can use the same code as given in that answer; just replace load -w <your_plist> with remove <your_bundle>.

Community
  • 1
  • 1
Rob Napier
  • 286,113
  • 34
  • 456
  • 610