Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

Repository files navigation

LaunchAtLogin

Build and test NuGet

A library that makes your app launch automatically when the user logs in to Windows. It respects the user turning it off in Task Manager's Startup apps.

How to use

Create one for your app:

var startupApp = new StartupApp(YOUR_APP_NAME);

snippet source | anchor

Add it to the user's startup apps, turned on:

startupApp.TurnOn();

snippet source | anchor

In your installer or updater, add it or update its command, without undoing the user turning it off:

startupApp.AddToStartupApps(/*optional path to exe*/);

snippet source | anchor

In your settings UI, check whether it's on:

var isOn = startupApp.IsOn;
//...

snippet source | anchor

Turn it off, the way Task Manager does:

startupApp.TurnOff();

snippet source | anchor

Remove it entirely, for example in your uninstaller:

startupApp.RemoveFromStartupApps();

snippet source | anchor

With Velopack

If you install and update your app with Velopack, add the LaunchAtLogin.Velopack package and register its hooks:

VelopackApp.Build()
    .KeepInStartupApps(new StartupApp(YOUR_APP_NAME))
    .Run();

It adds your app to the startup apps when Velopack installs it, turned on. After each update it rewrites the command, without undoing the user turning it off. It removes your app when Velopack uninstalls it. Your own Velopack hooks still run.

Don't also use Velopack's --shortcuts Startup option: it puts a second entry in the Startup folder, so your app launches twice.

Why a new library

No existing NuGet package does this. These were checked, by reading their source or unzipping the package, in November 2026:

Package What it does Why it doesn't fit
WindowsAutostartApi, AutostartManager, BootMeUp, RunOnStartup, StartupHelper Write the Run value or a Startup folder shortcut Never read or write StartupApproved
BlackSharp.Platform.Startup Uses Task Scheduler Task Manager's switch doesn't apply to scheduled tasks
Shiny.Core (AppStartupInstaller, 6.6 beta only) Reads the switch correctly Can't turn an app off the way Task Manager does, and pulls in dependency injection, logging and other packages
DevWinUI (StartupHelper) Writes the switch Its "off" marker is all zeros, which Windows reads as on
ManagedShell Reads the switch Only to launch other apps, as a shell replacement

A Windows desktop app that offers "launch at login" usually writes a value under HKCU\Software\Microsoft\Windows\CurrentVersion\Run. Windows also keeps a second, separate record: the on/off switch shown in Task Manager's Startup apps tab and in Settings > Apps > Startup. That switch lives in HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run. When the user turns an app off there, Windows leaves the Run value alone and writes a binary marker under StartupApproved\Run instead.

Apps that only look at the Run value get two things wrong:

  1. They show "on" in their own settings while Task Manager shows "off".
  2. When their installer or updater rewrites the Run value, some of them also clear the switch, which turns the app back on against the user's choice.

This library handles both records together, so an app's own setting and Task Manager always agree, and the user's choice survives installs and updates.

The thing no other package does is turn an app off exactly the way Task Manager does, so the app still appears in Task Manager's list, marked Disabled.

Development

  1. Install the .NET SDK.
  2. Run build-and-test.cmd.

To check that launching at login really works, run the end-to-end test. It needs you to log out and back in.

Out of Scope for now

  • Packaged (MSIX) apps. Windows redirects their HKCU writes into a private copy, so a Run value they write does nothing. They should use the windows.startupTask manifest extension and the StartupTask API instead.
  • All users (HKLM). It needs administrator rights, and Windows keeps a separate switch for it.
  • 32-bit apps on 64-bit Windows (Run32) and Startup folder shortcuts. They use different StartupApproved subkeys.
  • Command-line arguments. AddToStartupApps and TurnOn write only the quoted exe path. If a later version adds arguments, it needs Windows' command-line quoting rules (those of CommandLineToArgvW).
  • Opening the Startup apps settings page. An app can do that itself with Process.Start(new ProcessStartInfo("ms-settings:startupapps") { UseShellExecute = true }); the README can show that.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages