There may be times when you need to determine if a Microsoft Store app has been installed. You may have a dependency on that app or otherwise need to take action based on the presence of that app.
FindPackageForUser
The API PackageManager.FindPackageForUser() can do this. See the code below. Note the special handling for the various error conditions. This API returns a Package object if the app is installed for the current user. The API will throw an Access denied exception if 1) the app is not installed on the machine or 2) it is on the machine but not installed for the current user. The API will throw an Argument exception if the string for the package family name is not in the correct format.
publicstaticboolIsAppAlreadyInstalled(stringFullPackageFamilyName){varoPkgManager=newPackageManager();boolresult=false;try{//If 1st parameter is string.Empty, the packages are retrieved for the current user.PackageoPkg=oPkgManager.FindPackageForUser(string.Empty,FullPackageFamilyName);result=oPkg!=null;}catch(ArgumentExceptionsyse){Debug.WriteLine("Parameter Exception: Check Package full name argument for correct pattern. X.a_N.X.X.0x64__N");returnresult;}catch(UnauthorizedAccessExceptionsyse){if(!string.IsNullOrEmpty(syse.Message)){if(syse.Message.IndexOf("Access is denied",StringComparison.CurrentCulture)>=0){Debug.WriteLine("Access denied");returnresult;}}}catch(Exceptionex){if(!string.IsNullOrEmpty(ex.Message))Debug.WriteLine(@"Exception: {0}",ex.Message);returnresult;}returnresult;}privatevoidButton_Click(objectsender,RoutedEventArgse){// Sample code: This should return 'access denied' since this will not exist on your machinevarres=IsAppAlreadyInstalled("57012MikeFrancis.TrialTest123_1.66.5.0_x64__08pddan6qgabc");}
Full App Package Name
You need the full package name to call FindPackageForUser(). To get a list of all of the packages currently installed, you can use the PowerShell command Get-AppxPackage.
For the Microsoft Store apps that you have published, you can get the full package family name from the App Identity page in Partner Center. See screenshot below.
Please let me how this method works for you or if you have another solution for determining the installation status of an app on Windows 10.