Search code examples
objective-cmacoslaunchd

Mac OS X: In Objective-C or C, how to unload (stop) a LaunchDaemon managed by launched


I would like to know how to write Objective-C or C code to unload (stop) a LaunchDaemon. The LaunchDaemon that I want to unload is running as root user.

My question is basically the same as this one: How to Load LaunchDaemon plist from my Mac Application. The only difference is that he/she is trying to load, but I want to unload.


Solution

  • You can use applescript

    do shell script "launchctl unload /Library/LaunchDaemons/com.yourcompany.app.plist" with administrator privileges