3

I'm trying to create a Desktop Shortcut when my Desktop Bridge App is used for the first time.

I successfully can create a Desktop Shortcut pointing to the Application.ExecutablePath, but that generates an error when the user open the shortcuts. The error is regarding the user not having permission access to that folder.

I have research in the internet and found that the proper way is to do it with shell as this: shell:AppsFolder\{AppUserModelId}

But at least in Desktop-Bridge, when I instantiate Windows.ApplicationModel.AppInfo, it is always null.

The question being, where I can get the AppUserModelId, or is there another way to create a Desktop Shortcut in UWP/Desktop Bridge.

Thanks.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Felice
  • 33
  • 3

2 Answers2

3

To answer the question where to get the AppUserModelID:

The AUMID for a packaged app (DesktopBridge or UWP app) is simply composed of PackageFamilyName + "!" + PackageRelativeAppID.

With the Fall Creators Update we have also added a property on AppListEntry so you don't need to compose it yourself:
https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.core.applistentry#Properties

So to get the AUMID for your app you can call this:

string aumid = (await Package.Current.GetAppListEntriesAsync()).First().AppUserModelId;

(this is assuming that your package contains a single app)

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51
  • I can't get this to compile in VS 2015, it says AppUserModelId is not found in AppListEntry object. What should I do? – user173399 Jan 30 '22 at 05:33
2

I have research in the internet and found that the propper way is to do it with shell as this: shell:AppsFolder{AppUserModelId}

You could use the above way to create a shortcut for your app in Windows 8.1, but it is not recommend in Windows 10. Nowadays, you could drag your app's icon from Start to desktop to create a shortcut directly.

enter image description here

But at least in Desktop-Bridge when I instanciate Windows.ApplicationModel.AppInfo it is always null.

The Windows.ApplicationModel.AppInfo unavailable to a packaged desktop app. For more you could refer to this official documentation.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36