The new way of dealing with Startup Application in your MSIX package

Written by Alex Marin · November 28th, 2019

#MSIX

This article explores Microsoft's recommended solution for managing your Startup applications, when deployed as an MSIX package.

In terms of Win32 apps, which are natively installed on the system, there are many ways in which you can trigger a program to run at Startup.

You can choose to place:

  • a user registry key in HKCU\Software\Microsoft\Windows\CurrentVersion\Run
  • a machine registry key in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
  • add a shortcut in the Startup Folder

You can use:

  • C:\Users\< user ID>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup for the Startup Folder which operates at the user level and is unique to each user on the system
  • C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup for the Startup Folder which operates at the system level and it's shared among all user accounts on the system

However, with MSIX, you cannot use any of the above methods to trigger a program to run at Startup. Even if you have the registry key or the shortcut created inside the project, this does not work.

So let's see how you can accomplish this with MSIX.

StartupTask Class

With MSIX, the behavior of the application is determined by the AppXManifest.xml. Within this, for each defined application you can use the StartupTask Class to add an executable to run at startup.

For example, if you have a declared application like:

<Applications>
<Application Id="TheApp" Executable="TheApp.exe" EntryPoint="Windows.FullTrustApplication">
</Application>

You can add the following code:

<Extensions>
<desktop:Extension Category="windows.startupTask" Executable="VFS\TheApp.exe" EntryPoint="Windows.FullTrustApplication">
<desktop:StartupTask TaskId="TheApp" Enabled="true" DisplayName="The App" />
</desktop:Extension>
</Extensions>

In the end, the AppXManifest.xml should look something like this:

<Applications>
<Application Id="TheApp" Executable="TheApp.exe" EntryPoint="Windows.FullTrustApplication">
<Extensions>
<desktop:Extension Category="windows.startupTask" Executable="VFS\TheApp.exe" EntryPoint="Windows.FullTrustApplication">
<desktop:StartupTask TaskId="TheApp" Enabled="true" DisplayName="The App"/>
</desktop:Extension>
</Extensions>
</Application>
</Applications>
      

NoteNote: You must add the direct path to your executable.
Here, we have VFS\TheApp.exe, but this is different from application to application. For example, you could have Executable=”VSF\ProgramFiles64Folder\TheApp.exe”

Startup Application in Advanced Installer

Advanced Installer makes it easy for you to add this functionality to an MSIX package. Once you have a declared application in the Application Details page, navigate to the Declarations Page.

Once there, perform the following steps:

  1. Under Application Declarations, right-click your defined application
  2. Hover over Add Application Declaration
  3. Select Startup Task
Startup programs msix

You now have a Startup Task declared to your application in a few easy steps, using Advanced Installer, which automatically adds this to your AppXManifest.xml when the package is built.

Subscribe to Our Newsletter

Sign up for free and be the first to receive the latest news, videos, exclusive How-Tos, and guides from Advanced Installer.

Comments: