LeBrown Jones
LeBrown Jones

Reputation: 917

Is there a way to launch external .exe files and UWP apps from within my UWP app?

Basically I'd like to give users the ability to add shortcuts to other apps installed on their PC to my app so that they can launch them from within my app. I'd like for them to be able to launch Win32 apps AND UWP apps (Windows 10 Store apps). My app is not a file explorer, but users will simply have the ability to launch their favorite apps from within my app. I have my reasons for wanting this type of feature implemented. -__-

Upvotes: 1

Views: 961

Answers (1)

Nico Zhu
Nico Zhu

Reputation: 32775

Is there a way UWP apps from within my UWP app?

UWP has provide a way to query installed UWP app for current user. you could use FindPackagesForUser to get them. And then call GetAppListEntriesAsync to get app entry for each app. If you want launch the app, just call LaunchAsync method. For more please refer the following sample code.

private async void FindBtn_Click(object sender, RoutedEventArgs e)
{
    PackageManager manager = new PackageManager();
    var packages = manager.FindPackagesForUser(string.Empty);
    foreach (var package in packages)
    {

        var appEntries = await package.GetAppListEntriesAsync();
        var firstApp = appEntries.FirstOrDefault();
        if (firstApp != null)
        {
            await firstApp?.LaunchAsync();
        }

    }
}

Please note `` Before call FindPackagesForUser, you need enable packageQuery capability

<Package
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap" >

......

 <rescap:Capability Name="packageQuery" />

Is there a way to launch external .exe files

Currently, UWP has not provide such api to launch win32 app with path directly like classical desktop app, if you do want this feature, we suggest you make desktop extension for your UWP app, and get installed app and launch it within extension part.

Upvotes: 2

Related Questions