Search code examples
javascriptwindows-runtimewindows-store-appswindows-phone-8.1winjs

How to uninstall Windows Store App programmatically (JS)


I want to create a wipeout functionality for my windows store app so is there any way to uninstall Windows Store App programmatically in JavaScript ?


Solution

  • As others have already written, programmatic uninstall isn't available to Store-installed apps, by design.

    That said, it sounds like the intention behind your question is that you want to offer your users a way to guarantee, for example, that any personal information is wiped from the device and perhaps also the cloud. Fortunately, because the app itself is the agent that would save any such data, you're also in control of clearing it out. Doing so would return the app to the state it was on first install.

    Purging your appdata means the following:

    • Delete all files in the local and temp appdata folders.
    • Delete all local appdata settings in the settings container.
    • Clear out anything you put in the Windows.Storage.AccessCache.
    • Clear out any information you stored in the Windows.Storage.PasswordVault.

    I didn't mention roaming appdata files and settings for a reason. If you use roaming appdata, that data will be automatically retained in the cloud for some period of time even if all instances of the app on a user's devices are uninstalled. This is done by design so if a user happens to uninstall all instances of the all and then reinstall within about a month, their settings and data are still there. (Imagine cleaning off a laptop and a tablet so you can sell those, and then getting some new ones.)

    The upshot of this is that if you want to guarantee that data is wiped, then avoid using roaming appdata altogether. If you want to roam, then use another cloud service over which you have more control (e.g. tables in an Azure Mobile Service). This way you can specifically clear out all the data on user request.

    By doing all this, then you're able to give the user a way to clear everything out just short of uninstalling the app, leaving the app in a clean state and protecting any sensitive information.

    As an aside, you might be interested in this blog post of mine on the Windows Dev Blog, http://blogs.windows.com/buildingapps/2014/06/19/common-questions-and-answers-about-files-and-app-data-part-1-app-data/, and also the talk I did at //build 2013 called "The Story of State," http://channel9.msdn.com/Events/Build/2013/3-9118.