PackageManager.RemovePackageAsync(String) | removePackageAsync(String) method

Applies to Windows only

Removes a package for the current user asynchronously and receives progress and status messages on the removal operation. Dependency packages are also removed for the user if no other packages installed for the user depend on them.


IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress>^ RemovePackageAsync(
  String^ packageFullName



Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

A string representation of the package identity to identify the package to be removed.

Return value

Type: IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress>

The status of the deployment request. The DeploymentResult contains the final returned value of the deployment operation, once it is completed. The DeploymentProgress can be used to obtain the percentage of completion over the entire course of the deployment operation.


This request cannot be canceled. The package full name is an alternate form of the package identity that is shorter and is suitable for naming objects such as files and directories. A package identity is represented by the Identity element of the package manifest. When a package is removed it is removed for the current user, which means that the package payload continues to exist if other users have installed the package, but it will not be accessible to the current user. If no other users have the specified package installed, its payload will be removed from the %ProgramFiles%\WindowsApps directory. Any app associated with the package that is being removed will be shutdown automatically as part of the package removal.


Call the RemovePackageAsync(String) method to uninstall the app package. Notice that the package full name in packageFullName comes from a command-line argument.

RemovePackageAsync(String) returns an object that can be used to manage the asynchronous operation. Use the Completed property to set the delegate. Check the Status property to determine the status of the deployment operation. If the status is Error, the example calls the GetResults method to get additional error information.

using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Management::Deployment;

int __cdecl main(Platform::Array<String^>^ args)
    String^ inputPackageFullName = args[1];
    int returnValue = 0;

    PackageManager^ packageManager = ref new PackageManager();

    auto deploymentOperation = packageManager->RemovePackageAsync(inputPackageFullName);

    DeploymentResult^ deploymentOperationResult;

    // This event is signaled when the operation completes
    opCompletedEvent = CreateEvent(NULL, TRUE, FALSE, NULL);

    // Define the delegate
    deploymentOperation->Completed = 
        ref new AsyncOperationWithProgressCompletedHandler<DeploymentResult^, DeploymentProgress>(
        [&](IAsyncOperationWithProgress<DeploymentResult^, DeploymentProgress>^ operation, AsyncStatus)

    // Wait until the operation completes
    WaitForSingleObject(opCompletedEvent, INFINITE);

    // Check the status of the operation
    if ( deploymentOperation->Status == AsyncStatus::Error )
        auto deploymentResult = deploymentOperation->GetResults();
        wcout << L"Removal Error: " << deploymentOperation->ErrorCode.Value << endl;
        wcout << L"Detailed Error Text: " << deploymentResult->ErrorText->Data() << endl;
        returnValue = 1;
    else if ( deploymentOperation->Status == AsyncStatus::Canceled )
        wcout << L"Removal Canceled" << endl;
    else if ( deploymentOperation->Status == AsyncStatus::Completed )
        wcout << L"Removal succeeded!" << endl;
        wcout << L"Removal status unknown" << endl;
        returnValue = 1;

    return returnValue;


Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

None supported


Windows::Management::Deployment [C++]



See also

RemovePackageAsync(String, RemovalOptions)



© 2014 Microsoft