diff --git a/src/Titano.Setup/Views/SetupViewModel.cs b/src/Titano.Setup/Views/SetupViewModel.cs index 1b6d4aee..23d33222 100644 --- a/src/Titano.Setup/Views/SetupViewModel.cs +++ b/src/Titano.Setup/Views/SetupViewModel.cs @@ -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 } } - /// All users without administrator rights: an elevated copy installs with the chosen options. - private async Task InstallElevatedAsync(InstallRequest request, string? launch) + /// + /// All users without administrator rights: an elevated copy installs with the chosen options. This process + /// stays behind, hidden, to start unelevated if the copy asks for it. + /// + 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()