AutoLaunch 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AutoLaunch --version 1.0.0
                    
NuGet\Install-Package AutoLaunch -Version 1.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="AutoLaunch" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AutoLaunch" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AutoLaunch" />
                    
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 AutoLaunch --version 1.0.0
                    
#r "nuget: AutoLaunch, 1.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 AutoLaunch@1.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=AutoLaunch&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AutoLaunch&version=1.0.0
                    
Install as a Cake Tool

AutoLaunch

<img alt="AutoLaunch" src="https://raw.githubusercontent.com/Linlccc/AutoLaunch/master/docs/icon/icon.png" width="128">

English | 简体中文

NuGet Version NuGet Downloads GitHub License

AutoLaunch is a cross-platform .NET library that provides a unified API for enabling auto-start for applications and executables on Windows, Linux, and macOS systems.

✨ Features

  • 🌍 Cross-Platform Support: Windows, Linux, macOS
  • 🔧 Multiple Engines: Various implementations for each platform
  • 🎯 Ease of Use: Unified API across all platforms
  • 🛠 AOT Support: Fully supports AOT and trimming
  • 📦 Zero Dependency: No third-party library required

🚚 Supported Engines

Windows

Engine Description Permission Note
Registry Manage startup via registry User/Admin
StartupFolder Manage startup via startup folder User/Admin
TaskScheduler Manage startup via Task Scheduler Admin Can launch programs requiring admin rights

Linux

Engine Description Permission Note
Freedesktop Manage startup via Freedesktop standard User/Admin Requires a desktop environment supporting Freedesktop

macOS

Engine Description Permission Note
LaunchAgent Manage startup via Launch Agent User/Admin
AppleScript Manage startup items via login items Automation permission Only supports --hidden/--minimize arguments

📦 Installation

dotnet CLI:

dotnet add package AutoLaunch

Package Manager Console:

Install-Package AutoLaunch

🚀 Quick Start

Unified configuration API for all platforms

Basic Usage

using AutoLaunch;

// Automatically configure for current program
var autoLauncher = new AutoLaunchBuilder().Automatic().Build();

// Enable auto-launch synchronously
autoLauncher.Enable();
// Disable auto-launch synchronously
autoLauncher.Disable();
// Check if enabled synchronously
bool isEnabled = autoLauncher.IsEnabled();

// Enable auto-launch asynchronously
await autoLauncher.EnableAsync();
// Disable auto-launch asynchronously
await autoLauncher.DisableAsync();
// Check if enabled asynchronously
bool isEnabledAsync = await autoLauncher.IsEnabledAsync();

Custom Configuration

var autoLauncher = new AutoLaunchBuilder()
    .SetAppName("MyApp")
    .SetAppPath("/path/to/myapp")
    .SetArgs("arg1", "arg2")
    .AddArgs("arg3")
    .SetWorkScope(WorkScope.CurrentUser) // Set work scope for auto-launch
    .SetWindowsEngine(WindowsEngine.Registry) // Use Registry engine on Windows, ignored on other platforms
    .SetLinuxEngine(LinuxEngine.Freedesktop) // Use Freedesktop engine on Linux, ignored on other platforms
    .SetMacOSEngine(MacOSEngine.LaunchAgent) // Use LaunchAgent engine on macOS, ignored on other platforms
    .SetIdentifiers("com.example.myapp") // Add Bundle Identifier for macOS
    .SetExtraConfigIf(OperatingSystem.IsLinux(), "X-GNOME-Autostart-enabled=true") // Add extra config for Linux, must conform to Freedesktop standard
    .SetExtraConfigIf(OperatingSystem.IsMacOS(), "<key>KeepAlive</key><true/>") // Add extra config for macOS, must conform to LaunchAgent standard
    .Build();

autoLauncher.Enable();

Safe Mode

No exceptions will be thrown in safe mode

// Build an instance in safe mode
var autoLauncher = new AutoLaunchBuilder().Automatic().BuildSafe();

// Try to enable, returns true/false for success/failure
bool success = autoLauncher.TryEnable();

if(!success)
{
   // Get the last exception
    Exception? lastException = autoLauncher.TakeLastException();
    if (lastException is PermissionDeniedException) Console.WriteLine("Permission denied.");
    else Console.WriteLine($"Failed to enable auto-launch: {lastException?.Message}");
}

API Documentation

AutoLaunchBuilder

Method Description
Automatic() Automatically configure app name and path
SetAppName(string) Set app name
SetAppPath(string) Set app path
SetArgs(params string[]) Set startup arguments
AddArgs(params string[]) Add startup arguments
SetWorkScope(WorkScope) Set work scope (current user/all users)
SetWindowsEngine(WindowsEngine) Set Windows engine
SetLinuxEngine(LinuxEngine) Set Linux engine
SetMacOSEngine(MacOSEngine) Set macOS engine
SetIdentifiers(params string[]) Set identifiers (macOS LaunchAgent only)
AddIdentifiers(params string[]) Add identifiers (macOS LaunchAgent only)
SetExtraConfig(string) Set extra configuration
SetExtraConfigIf(bool, string) Conditionally set extra configuration
Build() Build AutoLauncher instance
BuildSafe() Build SafeAutoLauncher instance

AutoLauncher Interface

Method Description
Enable() Enable auto-launch
Disable() Disable auto-launch
IsEnabled() Check if enabled
EnableAsync() Enable auto-launch asynchronously
DisableAsync() Disable auto-launch asynchronously
IsEnabledAsync() Check if enabled asynchronously

SafeAutoLauncher Extra Methods

Method Description
TryEnable() Try to enable, returns success/failure
TryDisable() Try to disable, returns success/failure
TryIsEnabled() Try to check status, returns (success, enabled)
TryEnableAsync() Try to enable asynchronously
TryDisableAsync() Try to disable asynchronously
TryIsEnabledAsync() Try to check status asynchronously
TakeLastException() Get last exception

⚠️ Exception Types

Exception Description
AutoLaunchException Base exception class
AutoLaunchBuilderException Builder configuration error
UnsupportedOSException Unsupported operating system
PermissionDeniedException Permission denied
ExecuteCommandException Command execution failed

📜 License

Licensed under the terms of the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 194 9/6/2025
1.0.0 173 9/5/2025
1.0.0-preview.4 159 9/4/2025
1.0.0-preview.3 161 9/4/2025
1.0.0-preview.2 153 9/4/2025
1.0.0-preview.1 150 9/2/2025