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?