My goal is to suggest users to install the Store version of the app from the desktop app, but I need to know if the user can do it (e.g. its Windows 10+, and store is available).
I can easily detect Windows 10+.
The problem is that there are many SKUs like Windows Server and Windows LTSB, which do not have the Store, but provide essentially the same APIs.
What I've tried so far:
try
create an instance of Windows.Management.Deployment.PackageManager
The former succeeded on Windows Server, despite the lack of the Store.
The latter, while currently being adequate for today, requires checking for all non-Store SKUs manually, and does not really solve the problem, as nothing prevents Microsoft from introducing Windows Store into Windows 2019 LTSB.
Actually, more specifically, I want to know if the current user can install desktop bridge apps from Windows Store.
Select Start then enter Microsoft Store. Select it to open the app. If Microsoft Store won't launch, get more info at Microsoft Store does not launch.
If the Microsoft Store app isn't on the taskbar, it might have been unpinned. Here's how to search for it: Select Start and enter Microsoft Store. If you see it in the results, select it.
Sign in to Microsoft Store for Business or Microsoft Store for Education. Click Manage, and then choose Products and services. Click on the application to open the application settings, then select Private store availability. Select Everyone to make application available for all people in your organization.
You could use the Get-AppxPackage
PowerShell command to check whether the Microsoft.StorePurchaseApp
package is installed or not.
First, install the System.Management.Automation.dll
NuGet package using the Package Manager Console:
PM> Install-Package System.Management.Automation.dll
Then use a method like this:
public static bool IsStoreAvailable()
{
using (var shell = PowerShell.Create())
{
shell.AddScript("Get-AppxPackage -Name Microsoft.StorePurchaseApp");
var result = shell.Invoke();
return result.Any();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With