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

Replies

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"
  • Following up on this older thread—has anything changed in this regard in the last couple of years? Is an interactive removal (drag to trash, or equivalent achieved by AppleScript to the Finder) the only way to deactivate and remove a system extension?

  • I have the same question as @zygoat. Is there an MDM or non-MDM solution to programmatically remove the system extension? It looks like I need to delete the application and rebuild if I add new NEFilterRules to a content filter in my Network Extension.

  • @KarthikSiva : This is an ugly hack, but remarkably it seems to work on all recent versions of the OS: https://derflounder.wordpress.com/2021/10/26/silently-uninstalling-system-extensions-on-macos-monterey-and-earlier/.

    I hate to be an advocate for this kind of greasy workaround, but absent any updated direction from Apple, this is what we're going to be doing for now.

Add a Comment

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.

  • Hi could you elaborate more on how you update your system extension. What is the whole process like?

Add a Comment

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 ?