How to correctly remove a app with system extension via command line

If I install an app that includes a system extension I've noticed that when I remove this app the system extension remains.


I'm removing the app with `pkgutil --forget [PKG_NAME]` and deleting dependencies.


NOTE : I cannot disable SIP and have you to this remotely or via a script.


BR

On this note - why does the system extension not get removed from `systemextensionsctl list` After you've removed it ?


instead you see multiple rows with your extension all saying "[terminated waiting to uninstall on reboot]" yet they persist after rebooting and never disappear.


Surely its possible to properly remove these extensions.

What I've found is that you need to keep rebooting, they disappear one at a time and not all at once. If I forget to do a snapshot of my VM before a day of testing, I've found myself just sitting there at lunch restarting, time after time, until they're gone, just to make sure I have clean slate.

The only way to uninstall a system extension is to drag the container app to the trash.

Apple Engineer, please respond. How can I uninstall a system extension via the command line ?

Uninstalling the parent app via the normal method, leaves the system extension lying around, then theres no way to get rid of it!

How can I uninstall a system extension via the command line ?

john daniel’s response is correct: The only supported way to uninstall a system extension is to drag the container app to the trash.

Uninstall is a major hole in the sysex story right now )-: For example, you can currently install a sysex on a managed Mac but not uninstall it. The sysex team is aware of these problems (r. 67923914) but I’ve no info to share as to when they might be resolved.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Obviously we ran into the same problem. To keep the thread posted on what we tried and what seems to work well for us, here's what we did

  1. We first tried using Apple script to simulate the behavior of "dragging the app to trash". This did work sometimes. macOS did throw the popup saying something with extension is being moved to trash and things. However other times the container app got removed but the tied extension kept arnd running, putting system into weird state, requiring systemextensionsctl reset. After experimenting, we dropped this for our usecase.

  2. We exposed a command line switch in the app. During uninstall/upgrade, we launch the app with this new command line parameter, on seeing this, the app stops the extension using framework and then deactivates it. This cleans things up. Post this we delete the app. This has been holding well so far for us, but we are still experimenting with this.

If u happen to try this out, let me know if that works out for you as well. If there's any better strategy, do update the thread please.

Well this is were it becomes tricky.

I have 2 systemextentions left on my mac. They are leftovers from an antivirus software that I uninstalled using the only available method - which is and uninstall solution build by the antivirus company. This is all good, but I'm left with these 2 extensions. Now the question is - how do I get rid of them ?

According to this thread, the only supported way is to drag the parent application to the trash. This is not an option as the app is no longer installed. I no longer have a license for it, so reinstalling is not an option.

@Apple - As an OS supplier, you must be concerned about security, and having these different leftovers left in the system, that is no longer updated by the manufacturer cannot be good for security. There must be a way to uninstall them manually ?

How to correctly remove a app with system extension via command line
 
 
Q