Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Create Desktop Shortcut through an MSIX package

Thu Dec 09, 2021 11:02 am

Hi,

UPDATE: Starting with Advanced Installer v19.3 you can include a desktop shortcut in an MSIX package by simply creating the shortcut in "Desktop" folder from "Files and Folders" section of your setup project.

screenshot.jpg
screenshot.jpg (179.04KiB)Viewed 207980 times

When using previous Advanced Installer versions please use the workaround exposed below:

An MSIX package does not have built-in support to deploy a desktop shortcut, but using the "AppCompat" support in Advanced Installer you can include in an MSIX package a script that can create a shortcut to your application.

The current workaround solution uses the approach Microsoft exposed in "Create an application shortcut by running a script using Package Support Framework" article.

To implement this workaround you should include into your MSIX package:
1. a shortcut file configured to point to your application alias
2. a Start PowerShell script that all it does is to run once (when your application is first launched after MSIX installation) and copy the shortcut on Desktop location.

Here you can find a sample project attached.
sample.zip
(795.01KiB)Downloaded 1930 times

Let's suppose you have a WindowsFormsApp.exe desktop app that you package into an MSIX package created with an Advanced Installer setup project.

To include a desktop shortcut into your MSIX package here are the steps to proceed with:

1. open your setup project in Advanced Installer and go to "Declarations" tab

2. use the [Add Application Declaration] -> "App Alias" toolbar button to create an alias for your app (e.g. WindowsFormsApp.exe)
screen1.jpg
screen1.jpg (147.6KiB)Viewed 209770 times

3. build and install the MSIX setup project on your build machine

4. open Windows Run window ([Win] + [R]) and type in your app alias (e.g. WindowsFormsApp.exe); make sure your app successfully launches through your WindowsFormsApp.exe alias call after MSIX installation

5. now create a shortcut (e.g. WindowsFormsApp.lnk) pointing to your app alias (e.g. pointing to WindowsFormsApp.exe alias) and test it to make sure it successfully launches your app
screen3.jpg
screen3.jpg (40.13KiB)Viewed 209766 times

6. open in Windows Explorer the Application Data location of your installed MSIX package and copy in there the icon file you want to set for your shortcut, e.g. under path like this:

Code: Select all

%localappdata%\Packages\DemoPackage.MSIXDesktopShortcut_8njdae5dphm2p\LocalCache\Roaming\fooIcon.ico

7. right click on shortcut file and choose "Properties"

8. set the "Target" and "Start in" fields to "%localappdata%\Microsoft\WindowsApps\WindowsFormsApp.exe", respectively "%localappdata%\Microsoft\WindowsApps"

9. click on [Change Icon] button and set the icon for your shortcut to icon file placed in Application Data location of your installed MSIX package, e.g.

Code: Select all

%localappdata%\Packages\DemoPackage.MSIXDesktopShortcut_8njdae5dphm2p\LocalCache\Roaming\fooIcon.ico
screen4.jpg
screen4.jpg (77.69KiB)Viewed 209765 times
10. save your shortcut

11. uninstall the installed MSIX package and go back to your setup project in Advanced Installer

12. go to "Files and Folders" page and add your WindowsFormsApp.lnk shortcut file (using [Add Files] toolbar button) under "Application Folder" directory; do not import the shortcut file in Windows Installer format; also add the shortcut icon file (e.g. fooIcon.ico) under "User Profile > Application Data" directory

13. go to "AppCompat" page and add a "Start PowerShell Script" configured with these flags: RunOnce: true, ShowWindow: false, WaitForScriptToFinish: true and pointing to a .ps1 script with this code:

Code: Select all

Copy-Item "WindowsFormsApp.lnk" "$env:USERPROFILE\desktop\WindowsFormsApp.lnk"
screen2.jpg
screen2.jpg (135.78KiB)Viewed 209770 times
14. rebuild and test your MSIX package

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Bogdan
Posts: 2791
Joined: Tue Jul 07, 2009 7:34 am
Contact:  Website

Re: Create Desktop Shortcut through an MSIX package

Thu Jul 27, 2023 9:54 am

If you have Advanced Installer v19.3 or higher you don't need to follow the steps from this forum post. There is an easier built-in way to create a desktop shortcut, as described in this article:
https://www.advancedinstaller.com/handl ... -msix.html
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Sample Projects”