fix(setup): handle install-folder services, startup entries, shared shortcuts and data
- Windows services whose program lies in the install folder (Titano.Server --install-service) are found in the registry and, through the Service Control Manager, stopped before files are replaced (they join the "programs running" prompt), started again after an upgrade that stopped them, deleted when an upgrade drops their program and on uninstall. An unelevated setup runs that step in an elevated copy (/SERVICES=...). - The Server component installs for all users only (manifest allUsersOnly): choosing it moves a new install to Program Files and disables "Just me" with the reason; a per-user install cannot take it. - Uninstall removes every HKCU Run value that starts a program in the folder (the Uploader's "Start with Windows"). - A shortcut that already starts an existing program elsewhere is neither retargeted nor logged, and a logged shortcut is deleted only while it still starts a program of this folder, so the two products no longer remove each other's "Titano Uploader" shortcuts. - "Remove my data" lists and deletes only the data of this product's programs that no other installed Titano product uses (the desktop app and the Uploader share %LOCALAPPDATA%\Titano and its logs folder). - The .titano file type is named in setup's language (Setup.FileType.*). Setup tests run in Titano.App.Tests on Windows CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
32 files changed
+1175
-88
No files matched your search
@@ -35,6 +35,36 @@ internal static partial class SetupRegistry
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The logs of the other installations by <paramref name="publisher"/> (any product, either scope) except the one in
|
||||
/// <paramref name="directory"/>: what an uninstall must leave working (the user data they share).
|
||||
/// </summary>
|
||||
public static IReadOnlyList<InstallLog> OtherInstalls(string directory, string publisher)
|
||||
{
|
||||
var found = new List<InstallLog>();
|
||||
foreach (var scope in (ReadOnlySpan<InstallScope>)[InstallScope.CurrentUser, InstallScope.AllUsers])
|
||||
{
|
||||
using var root = Hive(scope).OpenSubKey(UninstallRoot.TrimEnd('\\'));
|
||||
if (root is null) continue;
|
||||
foreach (var name in root.GetSubKeyNames())
|
||||
{
|
||||
try
|
||||
{
|
||||
using var key = root.OpenSubKey(name);
|
||||
if (key?.GetValue("Publisher") is not string p || !p.Equals(publisher, StringComparison.Ordinal)) continue;
|
||||
if (key.GetValue("InstallLocation") is not string location || !Directory.Exists(location)) continue;
|
||||
if (CommandProgram.IsPathInside(location, directory) && CommandProgram.IsPathInside(directory, location)) continue;
|
||||
if (InstallLog.TryLoad(location) is { } log) found.Add(log);
|
||||
}
|
||||
catch (Exception ex) when (ex is System.Security.SecurityException or UnauthorizedAccessException or IOException)
|
||||
{
|
||||
// Another program's entry this account may not read.
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
public static void WriteUninstallEntry(InstallScope scope, string productKey, UninstallEntry entry)
|
||||
{
|
||||
using var key = Hive(scope).CreateSubKey(UninstallRoot + productKey, writable: true);
|
||||
|
||||
Reference in new issue
Block a user