Files
ThreadPilot/Services/IAutostartService.cs
PrimeBuild-pc 9c364a4506 feat: autostart for portable copies through the official installer, installs always in Program Files
- A portable copy that turns on autostart now offers to download, verify and
  install the official version through the update path (checksum required,
  admin-only folder); it never downgrades. The installed copy turns autostart
  on at its first start when the setting asks for it, after the stale-task
  cleanup, so it also self-heals a removed task.
- The installer no longer asks for a folder: always Program Files, the only
  place a non-admin program cannot replace the elevated exe. Installs in another
  folder move there on upgrade; only ThreadPilot's own files are removed from
  the old folder (the old uninstaller is not run: it deletes the user's settings).

Verified in Windows Sandbox: old install in C:\Apps moved to Program Files,
user file and settings kept, the installed app registered both tasks itself.
2026-10-22 10:54:37 +02:00

51 lines
1.6 KiB
C#

namespace ThreadPilot.Services
{
using System;
using System.Threading.Tasks;
public interface IAutostartService
{
event EventHandler<AutostartStatusChangedEventArgs>? AutostartStatusChanged;
bool IsAutostartEnabled { get; }
string? AutostartPath { get; }
/// <summary>Gets a value indicating whether this copy can autostart: only an install in Program Files can.</summary>
bool IsAutostartSupported { get; }
Task<bool> EnableAutostartAsync(bool startMinimized = true);
Task<bool> DisableAutostartAsync();
Task<bool> CheckAutostartStatusAsync();
Task<bool> UpdateAutostartAsync(bool startMinimized = true);
/// <summary>Turns autostart on when the user asked for it but this copy has no task yet (e.g. just installed).</summary>
Task EnsureAutostartAsync(bool startMinimized);
string GetAutostartArguments(bool startMinimized = true);
}
public class AutostartStatusChangedEventArgs : EventArgs
{
public bool IsEnabled { get; }
public bool StartMinimized { get; }
public string? RegistryPath { get; }
public Exception? Error { get; }
public AutostartStatusChangedEventArgs(bool isEnabled, bool startMinimized = false, string? registryPath = null, Exception? error = null)
{
this.IsEnabled = isEnabled;
this.StartMinimized = startMinimized;
this.RegistryPath = registryPath;
this.Error = error;
}
}
}