Self-update: UAC-aware, de-elevated relaunch, user-mode installer

Three coordinated changes so the auto-update flow works on every
existing install location.

LauncherSelfUpdater.cs
----------------------
- Probe the target directory with a write/delete of a temp file. If
  it fails (e.g. install in Program Files without admin), set
  UseShellExecute=true + Verb=runas on the Updater process so UAC
  prompts the user once for elevation. If the directory is writable
  (user-mode install or portable layout), skip elevation entirely.
- Switched from ProcessStartInfo.ArgumentList to a quoted Arguments
  string because Verb=runas requires UseShellExecute=true, which
  ignores ArgumentList. Paths get explicit quotes to survive spaces.

Updater Program.cs
------------------
After the file swap, the relaunch was a direct Process.Start(target).
With UAC elevation that propagates admin to the new launcher, then to
its child PROSERVE_UE_5_5.exe — undesirable. Replace with
`explorer.exe "<target>"`: explorer is always running in the user's
normal token, opens the exe via shell, the new process inherits the
non-elevated session. Standard de-elevation trick.

installer/PSLauncher.iss
------------------------
Switch from system-wide install (Program Files, requires admin) to
per-user (DefaultDirName={localappdata}\Programs\..., PrivilegesRequired=
lowest). Auto-update then never needs UAC at all on fresh installs.
Existing installs in Program Files keep working thanks to the runas
fallback above.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-02 10:57:32 +02:00
parent 56069f606d
commit f2a1de9aac
5 changed files with 45 additions and 15 deletions

View File

@@ -82,16 +82,21 @@ internal static class Program
return 4;
}
// 5. Relance
// 5. Relance.
// Si on a été lancé en admin (Verb=runas via UAC), un Process.Start direct
// propagerait l'élévation au launcher et donc à tous ses sous-processus
// (PROSERVE_UE_5_5.exe), ce qu'on ne veut pas. On passe par explorer.exe
// qui est non-élévé : il ouvre l'exe dans la session utilisateur normale.
if (opts.Launch)
{
try
{
Process.Start(new ProcessStartInfo
{
FileName = opts.Target,
UseShellExecute = true,
WorkingDirectory = Path.GetDirectoryName(opts.Target)!,
FileName = "explorer.exe",
Arguments = "\"" + opts.Target + "\"",
UseShellExecute = false,
CreateNoWindow = true,
});
}
catch (Exception ex)