Win11Debloat icon indicating copy to clipboard operation
Win11Debloat copied to clipboard

`Remove-AppxPackage -AllUsers` error on Windows 10

Open GuillaumeHullin opened this issue 1 year ago • 24 comments
trafficstars

Most of the Windows 10 (around 5-6 this week) I tried to run the debloat script failed to uninstall apps with the following error:

Attempting to remove Microsoft.549981C3F5F10...
Remove-AppxPackage : Échec de l’appel de procédure distante.
Échec de l’appel de procédure distante.
Au caractère C:\Users\FTAdmin\AppData\Local\Temp\Win11Debloat\Win11Debloat-master\Win11Debloat.ps1:374 : 98
+ ... ilter Main, Bundle, Resource -AllUsers | Remove-AppxPackage -AllUsers
+                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Remove-AppxPackage], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.Windows.Appx.PackageManager.Comman
   ds.RemoveAppxPackageCommand

I tried Microsoft updates, sfc, reset Microsoft Store, etc... no luck. Anybody?

GuillaumeHullin avatar Sep 21 '24 10:09 GuillaumeHullin

PS C:\WINDOWS\system32> Get-AppxPackage *Print3D* | Remove-AppxPackage -allusers
Remove-AppxPackage : Échec de l’appel de procédure distante.
Échec de l’appel de procédure distante.
Au caractère Ligne:1 : 29
+ Get-AppxPackage *Print3D* | Remove-AppxPackage -allusers
+                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Remove-AppxPackage], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.Windows.Appx.PackageManager.Comman
   ds.RemoveAppxPackageCommand

GuillaumeHullin avatar Sep 21 '24 10:09 GuillaumeHullin

Heya,

This looks similar to the issue that people encountered a while ago #74. It seems to stem from some kind of bug in Remove-AppxPackage that doesn't exist in Windows 11. I did implement a work-around specifically for Windows 10 that seemed to do the job, but maybe something changed?

I'll see if I can reproduce this issue myself and report back.

Raphire avatar Sep 21 '24 13:09 Raphire

There are two more data I can give you: 1- it only happens with systems which are have been used... I tried on a fresh windows 10, it works. 2- I have an other Windows 10 where the Microsoft store package seems to be broken... and the script work fine there.

GuillaumeHullin avatar Sep 21 '24 16:09 GuillaumeHullin

I found an Windows 10 22H2 with build 19045.4651... and there it works. All the other failing are build 19045.4894. So I'm guessing the problem is the latest upgrade... maybe reinstalling some components would help?

GuillaumeHullin avatar Sep 23 '24 10:09 GuillaumeHullin

Thanks again for the additional info, I have some trouble updating my w10 vm's, once I get them up to date I'll test and look for a solution.

Raphire avatar Sep 24 '24 10:09 Raphire

@GuillaumeHullin After updating my VM's I am now on 19045.4957. Uninstalling apps seems to work as expected. Could you see if updating your machines fixes the issue?

Raphire avatar Sep 25 '24 21:09 Raphire

I only have access right now to one Win10 but I don't have update available and I'm still at 19045.4894, how did you update?

GuillaumeHullin avatar Sep 25 '24 23:09 GuillaumeHullin

I only have access right now to one Win10 but I don't have update available and I'm still at 19045.4894, how did you update?

It seems to be a relatively new release, maybe it's a gradual roll-out. https://support.microsoft.com/en-us/topic/september-24-2024-kb5043131-os-build-19045-4957-preview-2d4a5c54-ac58-4bdb-8685-57d578650e5f

Raphire avatar Sep 26 '24 17:09 Raphire

Back on that problem, I got some Windows 10 with the build 19045.4894 and which had the same problem before and it still persists avec the update... any idea?

GuillaumeHullin avatar Sep 30 '24 20:09 GuillaumeHullin

Back on that problem, I got some Windows 10 with the build 19045.4894 and which had the same problem before and it still persists avec the update... any idea?

I have been able to reproduce it now on 19045.4894 aswell. It seems to be related to multiple users. Windows 10 seems to have this issue, while Windows 11 doesn't. There seem to be some other reports about this issue on the internet, but no clear reason or solution.

The only workaround that I have found to work is removing the -AllUsers flag from the command. This does however mean the script only uninstalls app for the current user.

Raphire avatar Sep 30 '24 21:09 Raphire

But the weird thing is that I have other Windows 10 updated to the same build, and I have no issue running the script. I was thinking maybe comparing some DLLs or other related files that could indicate a difference between the systems but so far I couldn't find anything.

GuillaumeHullin avatar Sep 30 '24 21:09 GuillaumeHullin

But the weird thing is that I have other Windows 10 updated to the same build, and I have no issue running the script. I was thinking maybe comparing some DLLs or other related files that could indicate a difference between the systems but so far I couldn't find anything.

Do those machines have multiple users?

Raphire avatar Sep 30 '24 21:09 Raphire

All of them. At least 2 admin accounts and one users. None of the admin accounts are linked to a Microsoft account. Some users are. No relations there. Some machines are part of a domain. No relations there either.

GuillaumeHullin avatar Sep 30 '24 22:09 GuillaumeHullin

All of them. At least 2 admin accounts and one users. None of the admin accounts are linked to a Microsoft account. Some users are. No relations there. Some machines are part of a domain. No relations there either.

Interesting, thanks for sharing these observations. Are all these machines on Windows 10?

Raphire avatar Sep 30 '24 22:09 Raphire

Yes, all Windows 10. On Windows 11 machines, it works fine.

GuillaumeHullin avatar Sep 30 '24 23:09 GuillaumeHullin

Yes, all Windows 10. On Windows 11 machines, it works fine.

Just to confirm: Are all Windows 10 machines affected, or do some Windows 10 machines work ok?

From what I can tell so far it seems to be related to Windows 10.

Raphire avatar Oct 01 '24 17:10 Raphire

Some Windows 10 machines works okay. I would say 50/50.

GuillaumeHullin avatar Oct 01 '24 21:10 GuillaumeHullin

@GuillaumeHullin Very weird indeed. I haven't found any solution for the issue so far, I'll update this thread when I do.

I did find out that app removal only seems bugged when using the -AllUsers switch. So I pushed an update that includes a sort of workaround to ensure the apps are atleast uninstalled for the current user.

Raphire avatar Oct 01 '24 22:10 Raphire

Some log from my Windows 10 problems. I tried a few different recently and no issues... until this one.

Attempting to remove Clipchamp.Clipchamp...
Unable to remove *Clipchamp.Clipchamp* for all users
   à System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   à Microsoft.Windows.Appx.PackageManager.Commands.RemoveAppxPackageCommand.RemovePackageForAllUsers(String packageFullName, Boolean& encounteredErrors)
   à Microsoft.Windows.Appx.PackageManager.Commands.RemoveAppxPackageCommand.ProcessRecord()
   à System.Management.Automation.CommandProcessor.ProcessRecord()
Attempting to remove Microsoft.3DBuilder...

GuillaumeHullin avatar Oct 10 '24 20:10 GuillaumeHullin

I did find out that app removal only seems bugged when using the -AllUsers switch. So I pushed an update that includes a sort of workaround to ensure the apps are atleast uninstalled for the current user.

Yes, I did see that too. Does your script log when uninstalling without the AllUsers switch?

GuillaumeHullin avatar Oct 10 '24 20:10 GuillaumeHullin

I did find out that app removal only seems bugged when using the -AllUsers switch. So I pushed an update that includes a sort of workaround to ensure the apps are atleast uninstalled for the current user.

Yes, I did see that too. Does your script log when uninstalling without the AllUsers switch?

It does log an error if the uninstall fails for the current user. Looking at the output you shared the uninstall did work for the current user.

Raphire avatar Oct 10 '24 21:10 Raphire

I did find out that app removal only seems bugged when using the -AllUsers switch. So I pushed an update that includes a sort of workaround to ensure the apps are atleast uninstalled for the current user.

Yes, I did see that too. Does your script log when uninstalling without the AllUsers switch?

It does log an error if the uninstall fails for the current user. Looking at the output you shared the uninstall did work for the current user.

Where do you see that it did work for the current user 😅 ?

GuillaumeHullin avatar Oct 10 '24 23:10 GuillaumeHullin

If removal fails for the current user it would show Unable to remove *Clipchamp.Clipchamp* for current user

Admittedly though the current implementation isn't the clearest.

Raphire avatar Oct 11 '24 11:10 Raphire

Oh okay. Good to know.

GuillaumeHullin avatar Oct 11 '24 11:10 GuillaumeHullin

I found an Windows 10 22H2 with build 19045.4651... and there it works. All the other failing are build 19045.4894. So I'm guessing the problem is the latest upgrade... maybe reinstalling some components would help?

The last upgrade of november 2024 KB5046613 (build 19045.5198) fixes the problem

carter1024 avatar Nov 29 '24 17:11 carter1024

I found an Windows 10 22H2 with build 19045.4651... and there it works. All the other failing are build 19045.4894. So I'm guessing the problem is the latest upgrade... maybe reinstalling some components would help?

The last upgrade of november 2024 KB5046613 (build 19045.5198) fixes the problem

That's good to hear, I'll see if I can test this version soon.

Raphire avatar Dec 04 '24 13:12 Raphire

Issue seems to indeed be fixed on W10 since build 19045.5198 as noted by @carter1024, so I'll close the issue.

Raphire avatar Dec 04 '24 16:12 Raphire