How to programmatically uninstall App that install DriverKit system extension

817 views Asked by At

I have an app that installs a DriverKit system extension when it launches.

If I then drag this app to the Bin from /Applications then I am prompted about that the app also manages a system extension and that the system extension also will be removed.

I would like to have an uninstaller that removes the app. I have tried to remove the app in the uninstaller with rm -rf, but then the system extension is not removed.

I have also tried the trash terminal utility (can be installed with brew install trash) to check if something similar could be used from the uninstaller, but without luck.

Is there a way to programmatically remove an app and also the system extension that the app installs.

1

There are 1 answers

1
pmdj On BEST ANSWER

Good question! I don't have a fully baked answer, but enough suggestions to try that they won't fit in a comment, so here goes anyway:

  • Try using Cocoa APIs for "trashing" files. This answer gives a good rundown. I don't know how this will cope with the system extension confirmation though.
  • If you definitely want to pop up the confirmation dialog, using AppleScript to tell the Finder to delete the file is a great approach. I can confirm the solution given in this answer works but it will show the confirmation dialog, which may or may not be what you want.
  • You can uninstall a system extension (including a dext) using the systemextensionsctl uninstall command. Unfortunately, this will always pop up an authentication dialog, even if you run it with root privileges. But depending on what you're doing, that might be preferable to the above.