How to set a auto startup for an WinUI app?

水 知 485 Reputation points
2026-08-11T03:25:24.4866667+00:00

Hi community,

I'm working with an WinUI app, but it can't auto start. I've declared uap5 and set it as an startup app at task manager, but it just can't work. I found some website about that and they say I should override OnActivated. But there's no OnActivated function in WinUI's App : Microsoft.UI.Xaml.Application I have no idea how to achive that. Please help.

Windows development | WinUI
0 comments No comments

Answer accepted by question author
Danny Nguyen (WICLOUD CORPORATION) 8,725 Reputation points Microsoft External Staff Moderator
2026-08-11T08:01:40.4833333+00:00

Hi @水 知 ,

Glad you found a solution, and thanks for linking the thread.

The manifest attributes are the blocker. Most guides are written for UWP, where the windows.startupTask extension is declared with Executable and EntryPoint. Both are optional in the schema, and in a WinUI 3 / Windows App SDK app they break the startup activation — the app gets launched at sign-in but never comes up. Removing them fixes it:

<uap5:Extension Category="windows.startupTask">
  <uap5:StartupTask TaskId="MyAppId" Enabled="false" DisplayName="MyApp startup" />
</uap5:Extension>

There's no OnActivated to override in WinUI 3. That's a UWP-only pattern, which is why the older guidance doesn't apply. Your app always comes in through OnLaunched, and LaunchActivatedEventArgs reports Launch even when Windows started it at sign-in. To detect a startup launch, read the activation args directly:

using Microsoft.Windows.AppLifecycle;

var args = AppInstance.GetCurrent().GetActivatedEventArgs();
if (args.Kind == ExtendedActivationKind.StartupTask)
{
    // launched at sign-in — e.g. start minimised to tray
}

Also keep in mind that this only works for packaged apps. Unpackaged, the manifest extension does nothing — you'd need a Startup folder shortcut or a Run registry entry.

If you found my response helpful or informative, I would greatly appreciate it if you could follow this guidance or provide feedback.

Thank you.

Was this answer helpful?

1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. 水 知 485 Reputation points
    2026-08-11T03:43:17.1133333+00:00

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.