RunAtStartup 6.0.0

dotnet add package RunAtStartup --version 6.0.0
                    
NuGet\Install-Package RunAtStartup -Version 6.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RunAtStartup" Version="6.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RunAtStartup" Version="6.0.0" />
                    
Directory.Packages.props
<PackageReference Include="RunAtStartup" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RunAtStartup --version 6.0.0
                    
#r "nuget: RunAtStartup, 6.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RunAtStartup@6.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RunAtStartup&version=6.0.0
                    
Install as a Cake Addin
#tool nuget:?package=RunAtStartup&version=6.0.0
                    
Install as a Cake Tool

RunAtStartup

CI NuGet

Register an unpackaged executable to start when the current user logs in, on Windows, Linux and macOS.

Usage

using RunAtStartup;

if (StartupService.IsSupported && Environment.ProcessPath is { } executablePath)
{
	// name: Windows Run value name, Linux .desktop file name and Name field
	// macOSLabel: LaunchAgent Label and .plist file name
	StartupService service = new("MyApp", "com.example.myapp");

	// Show the state of a "run at login" toggle
	bool enabled = service.Check(executablePath, "--minimized");

	// Turn it on or off
	service.Set(executablePath, "--minimized");
	service.Delete();

	// Point a registration left by an older install location at this executable
	if (service.Exists() && !service.Check(executablePath, "--minimized"))
	{
		service.Set(executablePath, "--minimized");
	}
}
  • Exists() returns whether a registration with this name exists, whatever it starts.
  • Check(path, args) returns whether the registration exists and is exactly what Set(path, args) would write. Together with Exists(), it detects a registration left behind by an older install location.
  • Set(path, args) creates or replaces the registration.
  • Delete() removes the registration and does nothing if there is none.

name and macOSLabel cannot be empty or contain control characters, / or \. name also cannot start with ., because the systemd XDG autostart generator skips hidden files on Linux.

The executable path and arguments are always passed explicitly; the library never reads Environment.ProcessPath.

Read and write failures are not caught: IOException, UnauthorizedAccessException and, on Windows, SecurityException propagate to the caller. On other platforms every instance method throws PlatformNotSupportedException.

Platforms

Platform Registration Command line
Windows HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, value name The path is always quoted; an argument is quoted and escaped by the CommandLineToArgvW rules only when it is empty or contains whitespace or ". Check compares case-insensitively.
Linux $XDG_CONFIG_HOME/autostart/{name}.desktop (~/.config/autostart when unset or not absolute) Exec is escaped by the Desktop Entry Specification. Check compares the whole file ordinally.
macOS ~/Library/LaunchAgents/{macOSLabel}.plist ProgramArguments holds the path and each argument; RunAtLoad is true. Check compares the whole file ordinally.

On macOS the file is only written; launchctl is not called, so the change takes effect at the next login.

Not supported

  • Registering for all users (HKEY_LOCAL_MACHINE, /etc/xdg/autostart, /Library/LaunchAgents).
  • Packaged apps: MSIX StartupTask, the Flatpak background portal and macOS SMAppService.
  • Platforms other than Windows, Linux and macOS.

Requirements

.NET 10 or later.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on RunAtStartup:

Repository Stars
HMBSbige/ShadowsocksR-Windows
Ship of Theseus
HMBSbige/BilibiliLiveRecordDownLoader
跨平台 B 站直播录制工具
Version Downloads Last Updated
6.0.0 92 11/30/2026
5.0.2 18,019 1/15/2021
5.0.0 1,140 11/28/2020