How to uninstall an app that another user installed?

77,817

Solution 1

My process above still works, but it simply gets around a race condition issue, where Windows Update (yes, oddly enough) is in charge of wiping out "staged packages."

According to Microsoft, the "other fix" - and I still consider this issue to be a bug - is:

Cause of the problem:

Windows Update (WU) downloads newer versions of packages you have and “stages” them as Local System, so that when you go to the store to update the apps, the update process is as quick as possible. WU will eventually clean up the staged packages that were never installed.

What are some consequences of having "Staged" packages?

  1. Staged packages prevent you from installing that particular package in development mode

  2. Staged packages eat up some disk space, but due to hardlinking, the effect of this is mitigated. If a file is identical between multiple versions of a package, appx deployment hardlinks the files instead of maintaining two separate copies of the same file.

How do I find the "Staged" packages?

  1. In an administrator powershell prompt, the command:

    get-appxpackage -all

will display all packages on the machine. For a staged package, the PackageUserInformation will show {S-1-5-18 [Unknown user]: Staged} 2. Using powershell filtering, to get the list of all staged packagefullnames, you could do:

get-appxpackage -all |% {if ($_.packageuserinformation.installstate -eq "Staged"){$_.packagefullname}}

How do I get rid of the "Staged" packages?

  1. Download psexec from sysinternals tools, written by Mark Russinovich

  2. To get rid of all of them, run in a regular admin/elevated command prompt (not powershell):

psexec -s powershell -c "get-appxpackage | remove-appxpackage"

Solution 2

There was an improvement in Windows 10 1709 to the remove-appxpackage cmdlet, adding -allusers as an option.

So, to uninstall an App for all users, this command works:

Get-AppxPackage -AllUsers [PackageFamilyName] | Remove-AppxPackage -AllUsers

Where [PackageFamilyName] is generally the GUID of your package.

Caveat / Caution: The command seems to make re-installation (re-provisioning the package using DISM) later very difficult, as it seems to treat is as if each user individually uninstalled the app. Too much to get into here...

Solution 3

If that doesn't work, you can also try the following, which worked for me. Note that this is for my dev machine, not a regular user's machine, so I don't know how it would affect non-devs :-P

  1. Take ownership of the folders c:\Program Files\WindowsApps and C:\ProgramData\Microsoft\Windows\AppRepository - giving Administrator full access. Make sure TrustedInstaller also has Modify rights as well. You're also taking ownership. If you're unawares, this is done via the Properties on that folder.

  2. Go to Services and stop the Windows Installer service.

  3. Open C:\ProgramData\Microsoft\Windows\AppRepository\ and delete the PackageRepository.edb file.

  4. Start the Windows Installer service again.

  5. Launch Visual Studio as Administrator.

  6. Attempt to launch your app. It should work.

After you run the app once you should be able to run VS in user mode again.

Solution 4

Workaround:

If nothing else works for you (for me it didnt either), you can just change your Package Name in your app manifest (just replace last few characters with another characters). When you do this, you will no longer have conflicting packages.

Changing package name may not be appropriate for some scenarios, but you can always back it up and change it back when you finished debugging on your problematic device....

Solution 5

If you want to delete the app for the current user then try:

Get-AppxPackage | where name -eq "APP.NAME" | Remove-AppxPackage

It helped me. So there is Get-AppxPackage without -all

Share:
77,817
Filip Skakun
Author by

Filip Skakun

UI developer, specializing in Microsoft client UI technologies from Win API and GDI through WinForms, DirectX, Surface/PixelSense, WPF, Silverlight, Windows Phone to Windows 10/UWP. By day - developing Windows apps at Microsoft. By night - developer of the WinRT XAML Toolkit https://github.com/xyzzer/WinRTXamlToolkit and blogger at http:/blog.onedevjob.com or more likely - still working on apps at Microsoft and pretending to know how to make music. By weekend - a family guy trying to make up for all that time spent developing! My words are mine and mine only and are not the official voice of my employer. Follow me on twitter at http://twitter.com/xyzzer

Updated on July 08, 2022

Comments

  • Filip Skakun
    Filip Skakun almost 2 years

    I keep hitting this problem when I try to debug my Windows 8 apps and there is a copy already installed on another user account:

    DEP0700 : Registration of the app failed. Another user has already installed a packaged version of this app. An unpackaged version cannot replace this. The conflicting package is {{{PackageName}}} and it was published by CN={{{Certificate Stuff}}}. (0x80073cf9)

    Sometimes I can just log in or ask someone else to log in to the machine and uninstall the app. Alternatively I can change the application name/id, but one is not always possible and the other is risky (I don't want to check in the changed application id to source control).

    There must be some way to uninstall it. Maybe a PowerShell script?

  • Filip Skakun
    Filip Skakun over 11 years
    Well, I hear there are issues when removing a user account will prevent all apps installed for that user to be removed from the list. I'm not sure if I did that, but I have an app now that I can't install on 2 out of 3 tablets I have at work because even though no user has the app installed - it still claims it is there and Get-AppxPackage -AllUsers shows it in the list. I can install it fine from the store, but not from Visual Studio. I think other apps install fine, so the problem is not with the dev license. I will check that again though the next time I look at it.
  • Alex Sorokoletov
    Alex Sorokoletov over 11 years
    Helped me to fix that strange issue. Had no other users on PC
  • Auri Rahimzadeh
    Auri Rahimzadeh over 11 years
    I have an open case with Microsoft on this. So far we've traced it to being a Visual Studio issue, since running the Powershell script to install the app works fine. I'll update this thread when we have resolution.
  • Alex Sorokoletov
    Alex Sorokoletov over 11 years
    Just today faced this issue on another surface device. Multiple users, single device, same app for every user. Asspain.
  • Irae Carvalho
    Irae Carvalho about 11 years
    To remove just the one package causing the problem, use I used the following line: psexec -s powershell -c "Get-AppxPackage -all | where name -eq "APP.NAME" | Remove-AppxPackage"
  • Nathan
    Nathan over 10 years
    Deleting the PackageRepository.edb prevents stuff from installing that has dependencies. It doesn't appear to rebuild the database. Even after multiple reboots, Get-AppxPackage -all returns no packages.
  • thumbmunkeys
    thumbmunkeys over 10 years
    psexec is not available for WinRT >:(
  • kkrizka
    kkrizka over 10 years
    Sadly this does not seem to work on Windows 8.1. When running from an Administrator command prompt, I get this error: Windows cannot remove 8eeaff03-92dd-46c9-84fc-7b252f93800b_1.0.0.0_neutral__9pm8dk‌​svrxpey because the current user does not have that package installed. Use Get-AppxPackage to see the list of packages installed.
  • Hong
    Hong over 10 years
    Unable to stop AppXSVC in order to delete the edb file.
  • Hong
    Hong over 10 years
    I had to restart the computer after executing the PS command in order to solve the problem. It is a W8.1 machine.
  • Martin Suchan
    Martin Suchan over 10 years
    I can confirm that even on Windows 8.1 I have found no way for uninstalling the app from already deleted account. Still investigating.
  • William Jockusch
    William Jockusch over 10 years
    Do I need to do anything afterwards to return my machine to normal operation? Change ownership back, for example?
  • John
    John about 10 years
    On 8.1, restarting did not fix the problem for me. This answer should no longer be marked as correct, since it unfortunately no longer applies to the majority of cases.
  • Jason Anderson
    Jason Anderson over 9 years
    For me, this was a life-saver. I worked on this for hours one night and finally gave up. I just re-ran into this issue and, for my immediate testing purposes, this is perfect! Thank you, Hendrix!
  • fnicollet
    fnicollet about 8 years
    I don't have any "PackageRepository.edb" file in that folder, only xml manifests and "StateRepository-Machine.srd" file. Tried everything that I could find online, Visual Studio still give me the same error "Invalid value for registry". Not sure what to try now
  • Filip Skakun
    Filip Skakun over 7 years
    Funny you just posted it as I was looking for the answer again. :) At least on TH2 it doesn't work, unfortunately. The first time you run it - it uninstalls it for the current user, but it still remains for the other one. Then when you rerun - you get: get-appxpackage -all | where name -eq "Microsoft.WindowsSoundRecorder" | Remove-AppxPackage Remove-AppxPackage : Deployment failed with HRESULT: 0x80073CF1, Package was not found. Windows cannot remove Microsoft.WindowsSoundRecorder_10.1611.3051.0_x64__8wekyb3d8‌​bbwe because the current user does not have that package installed. ...
  • kdazzle
    kdazzle over 7 years
    @FilipSkakun Oh bummer, you could be right - this could be a bad answer. I was running powershell as one user, but I gave it admin privileges with another user's credentials. And that admin user is the one that I was removing the app from. So that could be the source of my confusion.
  • ruffin
    ruffin over 7 years
    Pro-ish tip: Search with -like and use wildcards to find the name: Get-AppxPackage -all | Where Name -like "*P.NA*" But very well done; thanks. Only trouble I had was where a user still couldn't uninstall a sideloaded app (though it showed up with a Get-AppxPackage) and I had to "reinstall" via the AppPackage's Add-AppDevPackage.ps1 script to get it to ultimately behave.
  • Dr. Xperience
    Dr. Xperience over 6 years
    SqlLite Browser is unable to open the copy of StateReposity-Machine.srd
  • Dr. Xperience
    Dr. Xperience over 6 years
    I figured that out.
  • Dr. Xperience
    Dr. Xperience over 6 years
    I used this wonderfull tutorial to carry out the procedure. Now lets see.
  • Dr. Xperience
    Dr. Xperience over 6 years
    Update table names are package, packageuser and user respectively
  • Nico
    Nico about 6 years
    This worked for me after doing a Get-AppxPackage -AllUsers
  • Christian Findlay
    Christian Findlay almost 6 years
    Just FYI, this problem comes up because Windows 10 has a bug where "resetting" an app removes it but doesn't remove it properly. My app broke when I went in to the app settings and clicked Reset.
  • Christian Findlay
    Christian Findlay over 5 years
    I can't believe that this bug is still around. It's been around since the beginning of UWP development. It's disgusting.
  • Tam Bui
    Tam Bui about 5 years
    Finally! Something that isn't an outdated answer and actually worked for me. FYI, I was running Windows 10 1809. Tried Remove-AppxPackage so many times I was pulling my hair out. Saw this answer and then added "-AllUsers" and boom, the app finally got smoked. Thank you, @zax!
  • Filip Skakun
    Filip Skakun over 4 years
    You can really just do something like Get-AppxPackage -a *ageNam* | Remove-AppxPackage -a to remove a package based on name substring for all users without even the where part. You might still need psexec etc. to uninstall/remove files if your app is somehow stuck and only the system account is able to remove it.
  • Filip Skakun
    Filip Skakun over 2 years
    You can also use Get-AppxPackage -Name "MyPackageBlah" -A to check for the app for AllUsers and Get-AppxPackage -Name "MyPackageBlah" -A | Remove-AppxPackage -A to remove it in one go. This is all basically the same as Marc's answer.
  • Filip Skakun
    Filip Skakun over 2 years
    I think that's for preinstalled apps that come with the OS and it should be Get-ProvisionedAppxPackage.