Forum Discussion

AdreKiseque's avatar
AdreKiseque
Copper Contributor
Dec 10, 2024

Edge uninstallation fails through command line but works through GUI (Exit code 532) Windows 11 24H2

I'm putting together a Windows setup script, which involves configuring settings, installing things I want and uninstalling things I don't. Among the things I want to uninstall are the Microsoft Edge browser, but while I'm able to do so manually, I run into trouble trying through the command line, and by extension through my script.

Windows 11 Pro Edition Version 24H2, testing in VMs. Region is set to Germany. Uninstalling Edge through the Settings GUI works as expected, I click through a confirmation prompt or two and it gets ripped out. But when I run the uninstall string through the command line, it just fails silently after a few seconds, the only indication anything is happening being the cursor briefly changing to the "processing in background" variety. I'm just trying the standard `&"C:\Program Files (x86)\Microsoft\Edge\Application\*\Installer\setup.exe" --uninstall --system-level --force-uninstall` in PowerShell, but I've also tried filling in the wildcard with the full version number, manually navigating to the directory and running `.\setup.exe` directly, finagling with the flags and doing all the same through Command Prompt. With elevation, of course (though I did a few runs without to see if anything would happen). With some poking I've found setup.exe is terminating with exit code 532 (also the output if I try uninstalling through WinGet), but I've unfortunately not been able to find anything on that status online.

Interesting to note is this behaviour seems to be the same as when trying to uninstall through the GUI on older builds of 24H2. I recall on some of my earlier testing hitting uninstall in Settings would similarly fail silently after the UAC prompt, an error I and others reported, but it seemed to be corrected in an update.

Does anyone know what this exit code means? Or has experienced something similar before? Any idea how/if it can be fixed, or if it's just a bug of some kind? Thanks.

2 Replies

  • DashielQuinn's avatar
    DashielQuinn
    Iron Contributor

    Run winget uninstall Microsoft Edge --force as an administrator to force uninstall, or remove it through the system settings graphical interface.

    • AdreKiseque's avatar
      AdreKiseque
      Copper Contributor

      GUI is obviously not an option for an automated script. I don't believe I was familiar with a force flag for WinGet back when I was having this issue, but I rather doubt it would have worked. With a lot of troubleshooting I eventually managed to identify the error as Edge explicitely refusing to leave unless it had some kind of "approved" uninstaller, which is to say, even with the same command, it wouldn't actually run the uninstallation unless the parent process was Settings or Control Panel (SystemSettings.exe and dllhost.exe respectively). This in mind, I managed to get around the issue by using a PowerShell module to spoof the parent process, and like that it went nicely. You can see my full solution https://github.com/AdreKiseque/Windows-Setup-Scroll, lot more work than it should have been but I'll admit it was fun to figure out.

Resources