fix(startup): Start with Windows honours an entry Task Manager turned off

Task Manager's Startup tab keeps the Run value and writes a StartupApproved\Run value whose odd first byte means
off. The client and the Uploader now show such an entry as off; ticking the box removes the marker so the entry
runs again, unticking removes it with the Run value, and re-pointing the command after an update leaves it as it
is. Core/IO/StartupApproval holds the rule; the registry hive is injectable for tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-12 16:02:23 +00:00
1 parent b344d2a527
commit 8eaaef5085
5 files changed
+231 -47

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
namespace Titano.Core.IO;
/// <summary>
/// Whether Windows runs a sign-in entry (<see cref="StartupCommand"/>). Task Manager's Startup tab and Settings › Apps ›
/// Startup turn an entry off without touching its Run value: they write a binary value of the same name under
/// <see cref="RunKey"/> whose first byte is odd while the entry is off (0x03) and even once it is on again (0x02). An
/// entry without that value is on. Rewriting the Run value leaves it as it is, so turning an entry back on means
/// removing it.
/// </summary>
public static class StartupApproval
{
public const string RunKey = @"Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run";
/// <summary>The entry is turned off according to its StartupApproved <paramref name="state"/> (null when it has none).</summary>
public static bool IsTurnedOff(byte[]? state) => state is { Length: > 0 } && (state[0] & 1) != 0;
}