Silver Black 23 Posted October 20, 2021 (edited) Hi, I have a routine that I've been using successfully for a long time to start a process with admin rights elevation. But I've lately noticed that the UAC request is minimized in the task bar, instead I'd like it to appear full-screen as if the user had clicked on the executable himself. I'm using: FillChar(seExecShell, SizeOf(seExecShell), 0); seExecShell.cbSize := SizeOf(seExecShell); seExecShell.Wnd := hndCaller; seExecShell.fMask := SEE_MASK_NOCLOSEPROCESS; seExecShell.lpVerb := PWideChar(RUN_CMD); seExecShell.lpFile := PWideChar(fnFile); seExecShell.lpParameters := PWideChar(strParams); seExecShell.nShow := SW_SHOWNORMAL; Result := ShellExecuteEx(@seExecShell); ShellExecuteEx(@seExecShell); Then to manage the waiting for the the process to terminate: GetExitCodeProcess(seExecShell.hProcess, ExitCode); But even without waiting there is always the issue of the minimized UAC request. Do you think there is a workaround or this is a "by-design" feature of Windows? Edited October 20, 2021 by Silver Black 1 Share this post Link to post
FredS 138 Posted October 20, 2021 Its a bad feature: Disable Full-Screen Windows 10 User Account Control (UAC) Prompts On Your PC, Here’s How Share this post Link to post
Der schöne Günther 316 Posted October 21, 2021 Quote MSDN says ".. you must pass a parent HWND with a ShellExecute .." and explains, The UAC elevation mechanism uses the HWND as part of determining whether the elevation is a background or foreground elevation. If the application is determined to be a background application, the elevation is placed on the taskbar as a blinking button. .. Be sure to supply your foreground window's handle to ShellExecuteEx. Source: Sertac Akyuz, StackOverflow.com 1 1 Share this post Link to post
Silver Black 23 Posted October 21, 2021 23 hours ago, FredS said: Its a bad feature: Disable Full-Screen Windows 10 User Account Control (UAC) Prompts On Your PC, Here’s How No. First I don't want to disable it, second I cannot disable it on my users machines! Share this post Link to post
Silver Black 23 Posted October 21, 2021 9 hours ago, Der schöne Günther said: Source: Sertac Akyuz, StackOverflow.com Yes, it's already what I do. Share this post Link to post
FredS 138 Posted October 21, 2021 13 minutes ago, Silver Black said: I don't want to disable it My point was that your user can disable it which is why it may show up as you first described. Secondly, if an option can be set it can be read, that way at least you would be able to alert the user that such a thing might occur.. Share this post Link to post
David Heffernan 2345 Posted October 21, 2021 That's kind of odd. Does the same happen if you do this with a brand new vcl project? Share this post Link to post
Silver Black 23 Posted October 24, 2021 On 10/21/2021 at 9:06 PM, David Heffernan said: That's kind of odd. Does the same happen if you do this with a brand new vcl project? I've to try that with a brand new empty project, but it happens in two different project. Share this post Link to post
Silver Black 23 Posted October 24, 2021 On 10/21/2021 at 6:13 PM, FredS said: My point was that your user can disable it which is why it may show up as you first described. Secondly, if an option can be set it can be read, that way at least you would be able to alert the user that such a thing might occur.. Ok, now I get it. But the problem is that I've not disabled it on my machine and the issue occurs. Share this post Link to post
Der schöne Günther 316 Posted October 25, 2021 Is it just "your machine" or also others (virtual machines / Windows Sandbox)? Share this post Link to post
Lars Fosdal 1792 Posted October 25, 2021 I see minimized / background UAC dialogs from time to time, and it is annoying as heck. I can't really see a pattern, though - and I can't say 100% for sure, but I don't think our own app that requires elevation have behaved like this for me. Mostly, it seems to be installers, or apps launched by installers? Share this post Link to post
Silver Black 23 Posted October 26, 2021 On 10/25/2021 at 7:28 AM, Der schöne Günther said: Is it just "your machine" or also others (virtual machines / Windows Sandbox)? Also other VM/PC. On 10/25/2021 at 8:34 AM, Lars Fosdal said: I see minimized / background UAC dialogs from time to time, and it is annoying as heck. I can't really see a pattern, though - and I can't say 100% for sure, but I don't think our own app that requires elevation have behaved like this for me. Mostly, it seems to be installers, or apps launched by installers? My app is an installer! Share this post Link to post
Der schöne Günther 316 Posted October 26, 2021 It is what happens when the application that called ShellExecute did not provide a HWND of a foreground window. What is the value of your hndCaller ? Maybe you passed something like Application.Handle? Compare to GetForegroundWindow - Is your value the same? Share this post Link to post
FredS 138 Posted October 26, 2021 2 hours ago, Der schöne Günther said: It is what happens when the application that called ShellExecute did not provide a HWND of a foreground window. What is the value of your I also ran a couple of tests and it made no diff; Zero, GetDesktopHandle, GetActiveWindow, Application.Handle and Mainform.handle all appeared as normal. Share this post Link to post