Services, sign-in entries and shortcuts are matched against the full paths of the files the install log or the payload lists, never against everything under the install folder: an install into a shared folder such as D:\Apps or /DIR="C:\Program Files" no longer stops, starts or deletes other vendors' services or removes their Run values. The elevated step now takes the names the unelevated setup found (/SERVICES=... /NAMES=...) and reads each service again, acting only when it still starts a program of the folder's log or of its own payload (or, for Prune, a program of the folder that is gone). Programs are asked to close before any service is touched. On uninstall the services are deleted only once the programs have closed, just before the files go; a failed install or uninstall starts again the services it stopped, and after an upgrade setup starts exactly the services it stopped, whatever their start type. The Server component installs only for all users in a folder inside Program Files. In the window a custom folder outside it is invalid while the Server is selected, with a tooltip saying why; silent mode refuses it. An upgrade of an installation elsewhere cannot add the Server, and one it carried is dropped with its service. Sign-in entries use StartupCommand (the same file as on fix/shell-notify) and are removed by SetupRegistry.DeleteStartupEntries only when the client's or the Uploader's value starts a program the install log lists; an upgrade that drops a program removes its entry too. StartupEntries is gone. A shortcut that starts another product's existing copy is still left alone but now logged; uninstalling the product it starts hands it to another product of the same scope that lists it and has the same program, so the Uploader that stays keeps its shortcuts. Another registered Titano installation whose folder or log cannot be read now counts as using every program's data, so "Remove my data" never offers it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
59 lines
3.3 KiB
C#
59 lines
3.3 KiB
C#
using Titano.Core.IO;
|
|
using Titano.Testing;
|
|
|
|
namespace Titano.Core.Tests.Foundation;
|
|
|
|
/// <summary>The sign-in entries of the client and the Uploader: which copy they start, and which folder the uninstaller may clean.</summary>
|
|
public sealed class StartupCommandTests
|
|
{
|
|
private const string Installed = @"C:\Users\ada\AppData\Local\Programs\Titano\Titano.exe";
|
|
|
|
[Test]
|
|
public void TheCommandNamesItsProgram()
|
|
{
|
|
var command = StartupCommand.Format(Installed, "--minimized");
|
|
Assert.Equal("\"" + Installed + "\" --minimized", command);
|
|
Assert.Equal(Installed, StartupCommand.Executable(command));
|
|
Assert.Equal(@"C:\Users\ada\AppData\Local\Programs\Titano", StartupCommand.Folder(command));
|
|
// Written by hand or by an older tool: unquoted, or with spaces around.
|
|
Assert.Equal(@"D:\Titano\Titano.exe", StartupCommand.Executable(@" D:\Titano\Titano.exe --minimized "));
|
|
Assert.Equal(@"D:\Titano\Titano.exe", StartupCommand.Executable(@"D:\Titano\Titano.exe"));
|
|
Assert.Null(StartupCommand.Executable(null));
|
|
Assert.Null(StartupCommand.Executable(" "));
|
|
Assert.Null(StartupCommand.Executable("\"unterminated --minimized"));
|
|
Assert.Null(StartupCommand.Executable("\"\" --minimized"));
|
|
Assert.Null(StartupCommand.Folder("Titano.exe"));
|
|
Assert.Equal(@"D:\Titano", StartupCommand.FolderOf(@"D:\Titano\Titano.exe"));
|
|
}
|
|
|
|
[Test]
|
|
public void AnEntryBelongsToTheCopyItStarts()
|
|
{
|
|
var command = StartupCommand.Format(Installed, "--minimized");
|
|
Assert.True(StartupCommand.Starts(command, Installed));
|
|
Assert.True(StartupCommand.Starts(command, Installed.ToUpperInvariant()), "Windows paths ignore case");
|
|
// A portable copy on a USB stick, a second install or a development build is another program.
|
|
Assert.False(StartupCommand.Starts(command, @"E:\Titano\Titano.exe"));
|
|
Assert.False(StartupCommand.Starts(command, @"C:\Users\ada\AppData\Local\Programs\Titano\Titano.exe.old"));
|
|
Assert.False(StartupCommand.Starts(command, null));
|
|
Assert.False(StartupCommand.Starts(null, Installed));
|
|
}
|
|
|
|
[Test]
|
|
public void TheUninstallerRemovesOnlyTheEntriesOfItsFolder()
|
|
{
|
|
var client = StartupCommand.Format(Installed, "--minimized");
|
|
var uploader = StartupCommand.Format(@"C:\Users\ada\AppData\Local\Programs\Titano\Uploader\Titano.Uploader.exe", "--tray");
|
|
const string folder = @"C:\Users\ada\AppData\Local\Programs\Titano";
|
|
Assert.True(StartupCommand.StartsFrom(client, folder));
|
|
Assert.True(StartupCommand.StartsFrom(client, folder + @"\"));
|
|
Assert.True(StartupCommand.StartsFrom(uploader, folder.ToLowerInvariant()));
|
|
// A sibling folder that shares the name's start, another drive, or nothing at all stay.
|
|
Assert.False(StartupCommand.StartsFrom(StartupCommand.Format(@"C:\Users\ada\AppData\Local\Programs\Titano2\Titano.exe", "--minimized"), folder));
|
|
Assert.False(StartupCommand.StartsFrom(StartupCommand.Format(@"E:\Titano\Titano.exe", "--minimized"), folder));
|
|
Assert.False(StartupCommand.StartsFrom(StartupCommand.Format(folder, "--minimized"), folder));
|
|
Assert.False(StartupCommand.StartsFrom(null, folder));
|
|
Assert.False(StartupCommand.StartsFrom(client, @"\"));
|
|
}
|
|
}
|