fix(setup): remove the Task Manager state of a sign-in entry setup removes
Uninstalling (or an upgrade dropping a program) deleted the client's or the Uploader's Run value but left its StartupApproved\Run value behind. A moved entry keeps that state, so an entry the user turned off stays off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
2 files changed
+35
-12
No files matched your search
@@ -102,12 +102,17 @@ internal static partial class SetupRegistry
|
||||
/// <summary>
|
||||
/// Removes the sign-in entries of the client and the Uploader (<c>HKCU\…\Run</c>, written by the programs
|
||||
/// themselves) that start one of <paramref name="programs"/> (<see cref="CommandProgram.FullPaths"/> of the files an
|
||||
/// installation lists); another copy's entries, and other programs' values, stay.
|
||||
/// installation lists), with the on/off state Task Manager keeps for them (<see cref="StartupApproval"/>); another
|
||||
/// copy's entries, and other programs' values, stay.
|
||||
/// </summary>
|
||||
public static void DeleteStartupEntries(IReadOnlySet<string> programs) => MoveStartupEntries(programs, NoPrograms);
|
||||
|
||||
/// <summary><see cref="DeleteStartupEntries(IReadOnlySet{string})"/> in <paramref name="run"/>; returns the names removed.</summary>
|
||||
public static IReadOnlyList<string> DeleteStartupEntries(RegistryKey run, IReadOnlySet<string> programs) => MoveStartupEntries(run, programs, NoPrograms);
|
||||
/// <summary>
|
||||
/// <see cref="DeleteStartupEntries(IReadOnlySet{string})"/> in <paramref name="run"/> and <paramref name="approval"/>;
|
||||
/// returns the names removed.
|
||||
/// </summary>
|
||||
public static IReadOnlyList<string> DeleteStartupEntries(RegistryKey run, RegistryKey? approval, IReadOnlySet<string> programs) =>
|
||||
MoveStartupEntries(run, approval, programs, NoPrograms);
|
||||
|
||||
/// <summary>
|
||||
/// After an upgrade: a sign-in entry of the client or the Uploader that starts one of <paramref name="dropped"/>
|
||||
@@ -118,14 +123,18 @@ internal static partial class SetupRegistry
|
||||
public static void MoveStartupEntries(IReadOnlySet<string> dropped, IReadOnlyDictionary<string, string> programs)
|
||||
{
|
||||
using var run = Registry.CurrentUser.OpenSubKey(StartupCommand.RunKey, writable: true);
|
||||
if (run is not null) MoveStartupEntries(run, dropped, programs);
|
||||
if (run is null) return;
|
||||
using var approval = Registry.CurrentUser.OpenSubKey(StartupApproval.RunKey, writable: true);
|
||||
MoveStartupEntries(run, approval, dropped, programs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="MoveStartupEntries(IReadOnlySet{string}, IReadOnlyDictionary{string, string})"/> in
|
||||
/// <paramref name="run"/>; returns the names moved or removed.
|
||||
/// <paramref name="run"/>; a removed entry's on/off state goes from <paramref name="approval"/> too, a moved one keeps
|
||||
/// it. Returns the names moved or removed.
|
||||
/// </summary>
|
||||
public static IReadOnlyList<string> MoveStartupEntries(RegistryKey run, IReadOnlySet<string> dropped, IReadOnlyDictionary<string, string> programs)
|
||||
public static IReadOnlyList<string> MoveStartupEntries(RegistryKey run, RegistryKey? approval, IReadOnlySet<string> dropped,
|
||||
IReadOnlyDictionary<string, string> programs)
|
||||
{
|
||||
var changed = new List<string>();
|
||||
foreach (var name in (ReadOnlySpan<string>)[StartupCommand.ClientValue, StartupCommand.UploaderValue])
|
||||
@@ -140,6 +149,8 @@ internal static partial class SetupRegistry
|
||||
else
|
||||
{
|
||||
run.DeleteValue(name, throwOnMissingValue: false);
|
||||
// Its Task Manager state goes with it: nothing of the entry stays behind.
|
||||
approval?.DeleteValue(name, throwOnMissingValue: false);
|
||||
Titano.Core.Diagnostics.Log.Info("setup", $"Sign-in entry '{name}' removed");
|
||||
}
|
||||
changed.Add(name);
|
||||
|
||||
Reference in new issue
Block a user