@@ -752,19 +752,18 @@ public static string EnsureSafeQueryString(string query)
752752 private static extern bool AllowSetForegroundWindow ( int dwProcessId ) ;
753753
754754 /// <summary>
755- /// Windows: bring UniGetUI to the foreground and grant foreground rights so an imminent
756- /// UAC consent prompt surfaces in front instead of only flashing the taskbar (#5146).
757- /// No-op elsewhere, and when the app owns no visible foreground window to delegate.
755+ /// Windows: hand our foreground rights to the imminent UAC consent prompt so it surfaces
756+ /// in front instead of only flashing the taskbar (#5146). Windows decides whether we
757+ /// still hold that privilege and grants nothing once another app owns the foreground.
758+ /// Either way this only ever lets the consent UI come forward; it never activates our
759+ /// own window, so a minimized UniGetUI stays minimized (#5102). No-op elsewhere.
758760 /// Must be called immediately before launching the elevator.
759761 /// </summary>
760- public static async Task PrepareForegroundForElevationAsync ( )
762+ public static void PrepareForegroundForElevation ( )
761763 {
762764 if ( ! OperatingSystem . IsWindows ( ) )
763765 return ;
764766
765- var bringToFront = CoreData . BringMainWindowToForegroundAsync ;
766- if ( bringToFront is not null )
767- await bringToFront ( ) ;
768767 AllowSetForegroundWindow ( ASFW_ANY ) ;
769768 }
770769
@@ -824,7 +823,7 @@ public static async Task CacheUACForCurrentProcess()
824823
825824 // When admin-rights caching is enabled, the UAC consent prompt is raised here.
826825 // Surface it in front instead of letting it flash unnoticed in the taskbar (#5146).
827- await PrepareForegroundForElevationAsync ( ) ;
826+ PrepareForegroundForElevation ( ) ;
828827
829828 p . Start ( ) ;
830829 await p . WaitForExitAsync ( ) ;
0 commit comments