fix(setup): let the elevated window's Launch start the program unelevated

The unelevated parent now always knows the program path, so Launch on the
success screen of an elevated all-users install works even when "Start when
done" was not ticked.

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-02 10:27:07 +00:00
1 parent ee1ba9a4ad
commit 028aa977f4
1 file changed
+8 -5
+8 -5
View File
@@ -343,7 +343,7 @@ internal sealed class SetupViewModel : LocalizedViewModel, INotifyDataErrorInfo
if (request.Scope == InstallScope.AllUsers && !Elevation.IsElevated)
{
await InstallElevatedAsync(request, launch);
await InstallElevatedAsync(request, program);
return;
}
if (!await EnsureProgramsClosedAsync(request.Directory, InstallPlan.Programs(engine.Manifest, request.Directory))) return;
@@ -361,8 +361,11 @@ internal sealed class SetupViewModel : LocalizedViewModel, INotifyDataErrorInfo
}
}
/// <summary>All users without administrator rights: an elevated copy installs with the chosen options.</summary>
private async Task InstallElevatedAsync(InstallRequest request, string? launch)
/// <summary>
/// All users without administrator rights: an elevated copy installs with the chosen options. This process
/// stays behind, hidden, to start <paramref name="program"/> unelevated if the copy asks for it.
/// </summary>
private async Task InstallElevatedAsync(InstallRequest request, string? program)
{
if (_arguments.Elevated) throw new SetupException(SetupExitCode.ElevationDeclined, "Still not elevated after relaunch.");
var switches = new SetupArguments
@@ -372,12 +375,12 @@ internal sealed class SetupViewModel : LocalizedViewModel, INotifyDataErrorInfo
AllUsers = true,
NoDesktopShortcut = !request.DesktopShortcuts,
NoStartMenu = !request.StartMenuShortcuts,
Launch = launch is not null,
Launch = _launchAfter,
Language = Loc.Culture.Name,
};
var child = Elevation.Start(switches, WindowHandle) ?? throw new SetupException(SetupExitCode.ElevationDeclined, "Administrator approval declined.");
VisibilityRequested?.Invoke(this, false);
Finish(await Elevation.WaitAsync(child, launch));
Finish(await Elevation.WaitAsync(child, program));
}
private async Task UninstallAsync()