Windows apps
Collapse the table of content
Expand the table of content

How to remove a package

[This documentation is preliminary and is subject to change.]

Learn how to remove an app package using the package deployment API.


Step 1: Get the full name of the package

Prompt your user for the full name of the package to be removed. For example, sampleapp_1.0.0.0_neutral_en-us_ab1c2d3efghij. Here's an example from a command-line app that stores the URI in the variable named inputPackageFullName.

if (args.Length < 1)    
    Console.WriteLine("Usage: RemovePackageSample.exe packageFullName");
    return 1;

string inputPackageFullName = args[0];

Step 2: Create a package manager object

Declare a variable of type Windows.Management.Deployment.PackageManager.

using Windows.Management.Deployment;

PackageManager packageManager = new PackageManager();

Step 3: Start the deployment operation

Call the PackageManager.RemovePackageAsync method to uninstall the app package. The parameter specifies the package full name in inputPackageFullName, which we created in the first step.

RemovePackageAsync returns an object that you can use to manage the asynchronous operation. Use the Completed property to set the event handler.

IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress> deploymentOperation = 

ManualResetEvent opCompletedEvent = new ManualResetEvent(false); // signaled when the operation completes

deploymentOperation.Completed = (depProgress, status) => { opCompletedEvent.Set(); };


Step 4: Check the results of the asynchronous deployment operation

Check DeploymentOperation.Status to determine the status of the deployment operation. The example calls the DeploymentOperation.GetResults method to get additional error information.

if (deploymentOperation.Status == Windows.Foundation.AsyncStatus.Error)
    DeploymentResult deploymentResult = deploymentOperation.GetResults();
    Console.WriteLine("Error code: {0}", deploymentOperation.ErrorCode);
    Console.WriteLine("Error text: {0}", deploymentResult.ErrorText);
else if (deploymentOperation.Status == Windows.Foundation.AsyncStatus.Canceled)
    Console.WriteLine("Removal canceled");
else if (deploymentOperation.Status == Windows.Foundation.AsyncStatus.Completed)
    Console.WriteLine("Removal succeeded");
    Console.WriteLine("Removal status unknown");


You can't use the deployment API in a Metro style app.

Complete example

To download the complete sample, see Remove app package sample.

Related topics

App packages and deployment



Send comments about this topic to Microsoft

Build date: 4/20/2012

Community Additions

© 2016 Microsoft