Remove auto-start: launcher owns the app lifecycle
The TeslaConsole launcher starts and stops RIOJoy, so the app no longer registers any auto-start entry: - install-rio.ps1: drop the HKLM ...\Run registration and the post-install launch (and the -NoLaunch param). - Tray: remove the "Start with Windows" menu item and delete AutoStartManager (HKCU ...\Run writer). - AppConfig: drop the now-inert AutoStart field (+ test). - Docs (PLAN.md, README-DEPLOY.txt) updated to reflect launcher-managed start/stop. uninstall-rio.ps1 still clears any leftover Run entry from older auto-starting builds. Solution builds; 241 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -29,9 +29,6 @@ public sealed class AppConfig
|
||||
/// </summary>
|
||||
public string? NeutralProfileName { get; set; }
|
||||
|
||||
/// <summary>Start RIOJoy with Windows.</summary>
|
||||
public bool AutoStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Path to the cockpit overlay template (<c>regions.json</c>) used to generate
|
||||
/// per-profile wallpapers (Phase 7). Null disables wallpaper generation. The
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace RioJoy.Tray.Os;
|
||||
|
||||
/// <summary>
|
||||
/// Manages the Windows "run at login" registration via the per-user
|
||||
/// <c>Run</c> registry key. Per-user (HKCU) needs no elevation and matches the
|
||||
/// tray app running in the interactive session.
|
||||
/// </summary>
|
||||
public static class AutoStartManager
|
||||
{
|
||||
private const string RunKey = @"Software\Microsoft\Windows\CurrentVersion\Run";
|
||||
private const string ValueName = "RIOJoy";
|
||||
|
||||
public static bool IsEnabled()
|
||||
{
|
||||
using RegistryKey? key = Registry.CurrentUser.OpenSubKey(RunKey);
|
||||
return key?.GetValue(ValueName) is not null;
|
||||
}
|
||||
|
||||
public static void SetEnabled(bool enabled)
|
||||
{
|
||||
using RegistryKey key = Registry.CurrentUser.CreateSubKey(RunKey);
|
||||
if (enabled)
|
||||
key.SetValue(ValueName, $"\"{Application.ExecutablePath}\"");
|
||||
else
|
||||
key.DeleteValue(ValueName, throwOnMissingValue: false);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ namespace RioJoy.Tray;
|
||||
internal static class Program
|
||||
{
|
||||
// Per-session single-instance guard. Two instances would both grab the RIO COM
|
||||
// port, so a second launch (e.g. machine-wide + per-user autostart both firing)
|
||||
// must exit immediately. A named mutex is released by the OS if the owner dies,
|
||||
// port, so a second launch (e.g. the launcher starting it while an instance is
|
||||
// already running) must exit immediately. A named mutex is released by the OS if the owner dies,
|
||||
// so a crash never leaves a stale lock.
|
||||
private const string SingleInstanceMutex = "RIOJoy.Tray.SingleInstance";
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ namespace RioJoy.Tray;
|
||||
/// <summary>
|
||||
/// Owns the tray icon, menu, and the RIOJoy runtime. The menu mirrors the legacy
|
||||
/// console menu (axis resets, version/status, diagnostic toggles, quit) and adds
|
||||
/// profile selection (auto vs. manual) and a "start with Windows" toggle. The
|
||||
/// profile selection (auto vs. manual). The app's start/stop lifecycle is owned by
|
||||
/// the TeslaConsole launcher, so there is no "start with Windows" toggle. The
|
||||
/// auto-switch watcher is polled on a UI timer so menu/status updates stay on the
|
||||
/// UI thread.
|
||||
/// </summary>
|
||||
@@ -91,14 +92,8 @@ internal sealed class TrayApplicationContext : ApplicationContext
|
||||
|
||||
menu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
var autoStart = new ToolStripMenuItem("Start with Windows")
|
||||
{
|
||||
CheckOnClick = true,
|
||||
Checked = AutoStartManager.IsEnabled(),
|
||||
};
|
||||
autoStart.Click += (_, _) => AutoStartManager.SetEnabled(autoStart.Checked);
|
||||
menu.Items.Add(autoStart);
|
||||
|
||||
// No "start with Windows" toggle: the TeslaConsole launcher owns the app's
|
||||
// start/stop lifecycle, so RIOJoy deliberately registers no auto-start entry.
|
||||
menu.Items.Add("Exit", null, (_, _) => Quit());
|
||||
|
||||
return menu;
|
||||
|
||||
Reference in New Issue
Block a user