PackageManager.FindPackages(String, String) method

Applies to Windows only

Finds all installed packages with the specified name and publisher.

Syntax


public IEnumerable<Package> FindPackages(
  string packageName, 
  string packagePublisher
)

Parameters

packageName

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

The package name. This parameter cannot be null.

packagePublisher

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

The package publisher. This parameter cannot be null.

Return value

Type: IIterable<Package> [C++] | System.Collections.Generic.IEnumerable<Package> [.NET]

If the method succeeds, an enumerable collection of package objects with the same package name and publisher name is returned. Each Package object in this collection contains information about the package, including but not limited to its name, publisher, version, and install location. If no packages with the specified name and publisher are found, this method returns an empty list.

Remarks

This method requires administrative privileges. Each package in the IIterable(Package) collection may be installed for the current user or for another user. This method differs from FindPackages(String packageFamilyName) because the parameters specified must be the package name and the package publisher name, not the package family name which includes the publisher hash value.

Examples

This example uses FindPackages(String, String) to enumerate the installed packages with the specified name and publisher.


using Windows.Management.Deployment;

public static int Main(string[] args)
{
    PackageManager packageManager = new PackageManager();

    string inputPackageName = args[0];
    string inputPublisherName = args[1];

    IEnumerable<Windows.ApplicationModel.Package> packages = 
        (IEnumerable<Windows.ApplicationModel.Package>)packageManager.FindPackages(
            inputPackageName, 
            inputPublisherName);

    int packageCount = 0;
    foreach (var package in packages)
    {
        DisplayPackageInfo(package);
        Console.WriteLine();
        packageCount += 1;
    }

    if (packageCount < 1)
    {
        Console.WriteLine("No packages were found.");
    }

    return 0;
}

private static void DisplayPackageInfo(Windows.ApplicationModel.Package package)
{
    Console.WriteLine("Name: {0}", package.Id.Name);

    Console.WriteLine("FullName: {0}", package.Id.FullName);

    Console.WriteLine("Version: {0}.{1}.{2}.{3}", package.Id.Version.Major, package.Id.Version.Minor,
        package.Id.Version.Build, package.Id.Version.Revision);

    Console.WriteLine("Publisher: {0}", package.Id.Publisher);

    Console.WriteLine("PublisherId: {0}", package.Id.PublisherId);

    Console.WriteLine("Installed Location: {0}", package.InstalledLocation.Path);

    Console.WriteLine("IsFramework: {0}", package.IsFramework);
}

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

None supported

Namespace

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

Metadata

Windows.winmd

See also

Samples
Enumerate app packages by name and publisher sample
Reference
FindPackages()
FindPackages(String)
PackageManager

 

 

Show:
© 2014 Microsoft