7
votes

I have an issue where the Windows 8 User Account Control (UAC) popup is minimized when I execute a command line helper program that requests admin privileges in its manifest. The UAC popup window just blinks yellow in the Windows taskbar, causing a confusing user experience:

Minimized UAC

After clicking the taskbar icon, then the UAC alert shows:

UAC Alert

In Windows 7, the UAC alert is not minimized but shows in the foreground. Any thoughts on how to fix this in Windows 8?

For reference, my main application runs under user privilege and executes the helper program with ShellExecuteEx. I am setting ShellExecuteEx's TShellExecuteInfo.nShow to SW_SHOW.

1
The difference is your command line helper is not in the foreground for the former. Windows 7 behaves the same for non-foreground prompts.Sertac Akyuz
Any way to foreground the command line helper?spurgeon
Not sure. See "Use the HWND Property to Be Acknowledged as a Foreground Application" part here if it helps.Sertac Akyuz
At a wild guess you're not passing in the correct window handle to ShellExecuteEx.Petesh
@SertacAkyuz and @Petesh Thank you. I had a popup TForm that was executing the exe and I was specifying Application.Handle to ShellExecuteEx rather than the TForm.Handle (which has focus when executing the command line helper). +1s and I'll accept an answer if you like too.spurgeon

1 Answers

8
votes

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.