2
votes

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 propper way is to do it with shell as this: shell:AppsFolder{AppUserModelId}

But at least in Desktop-Bridge when I instanciate 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.

2

2 Answers

3
votes

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://docs.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)

2
votes

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.