fix(setup): an upgrade moves a renamed program's sign-in entry instead of deleting it
RemoveLeftovers deleted every Titano or Titano Uploader Run value that started a file the upgrade removed, including a client or Uploader the new version only renamed or moved. The new program then found no entry to follow and Start with Windows was silently off. Setup now points such an entry at the program of the same component in the new payload (its shortcut target), keeping the options and the value name, and removes it only when the component is no longer installed. Uninstall still removes the entries of the programs its log lists. StartupCommand.StartsFrom, left over from the superseded folder-scoped cleanup, is gone; StartupCommand.Retarget replaces it and its misleading test now covers how setup moves an entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
6 files changed
+141
-41
No files matched your search
@@ -3,7 +3,8 @@ namespace Titano.Core.IO;
|
||||
/// <summary>
|
||||
/// The sign-in entries of Titano's programs: <c>HKCU\Software\Microsoft\Windows\CurrentVersion\Run</c> values whose
|
||||
/// command starts one executable with one option (<c>"C:\…\Titano.exe" --minimized</c>). Shared by the programs that
|
||||
/// write them and the uninstaller that removes them; the paths are Windows paths, compared ignoring case.
|
||||
/// write them and setup, which moves or removes them with the programs it installed; the paths are Windows paths,
|
||||
/// compared ignoring case.
|
||||
/// </summary>
|
||||
public static class StartupCommand
|
||||
{
|
||||
@@ -39,13 +40,18 @@ public static class StartupCommand
|
||||
public static bool Starts(string? command, string? executable) =>
|
||||
executable is { Length: > 0 } && string.Equals(Executable(command), executable, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>The program <paramref name="command"/> starts lies in <paramref name="directory"/> or one of its folders.</summary>
|
||||
public static bool StartsFrom(string? command, string directory)
|
||||
/// <summary>
|
||||
/// <paramref name="command"/> made to start <paramref name="executable"/> with the same options (setup moves an entry
|
||||
/// to the program an update renamed); null when <paramref name="command"/> names no program.
|
||||
/// </summary>
|
||||
public static string? Retarget(string? command, string executable)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(directory);
|
||||
var folder = directory.TrimEnd('\\', '/');
|
||||
return Executable(command) is { } exe && folder.Length > 0 && exe.Length > folder.Length + 1
|
||||
&& exe.StartsWith(folder, StringComparison.OrdinalIgnoreCase) && exe[folder.Length] is '\\' or '/';
|
||||
ArgumentNullException.ThrowIfNull(executable);
|
||||
if (Executable(command) is null) return null;
|
||||
var text = command!.Trim();
|
||||
var end = text[0] == '"' ? text.IndexOf('"', 1) + 1 : text.IndexOf(' ', StringComparison.Ordinal);
|
||||
var options = end < 0 ? string.Empty : text[end..].Trim();
|
||||
return options.Length == 0 ? $"\"{executable}\"" : Format(executable, options);
|
||||
}
|
||||
|
||||
/// <summary>The folder of the program <paramref name="command"/> starts; null when it names none.</summary>
|
||||
|
||||
Reference in new issue
Block a user