question

HerlinDrew-1234 avatar image
0 Votes"
HerlinDrew-1234 asked saldana-msft edited

How to detect UAC prompt appearance programmatically?

Hello everyone,

This makes me stuck for a while. How do I detect UAC prompt appearing by Win32 C++ application on Windows 10(Home, Pro...19H2 and later)?

windows-10-generalwindows-10-security
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CarlFan-MSFT avatar image
0 Votes"
CarlFan-MSFT answered CarlFan-MSFT commented

Hi,
Based on my search, Windows automatically elevates applications based on various criteria.
Before a 32 bit process is created, the following attributes are checked to determine whether it is an installer:
Filename includes keywords like "install," "setup," "update," etc.
Keywords in the following Versioning Resource fields: Vendor, Company Name, Product Name, File Description, Original Filename, Internal Name, and Export Name.
Keywords in the side-by-side manifest embedded in the executable.
Keywords in specific StringTable entries linked in the executable.
Key attributes in the RC data linked in the executable.
Targeted sequences of bytes within the executable.
So it seems related to application Manifest.
For this issue, I suggest that you may post it to MSDN dev forum.

The reason I we recommend posting appropriately is you will get the most qualified pool of respondents for Win32C++ issue.

Best Regards,
Carl

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi:

Your reply is very useful to expend my knowledge but still answer my question. Me trying to do is like a daemon process doing some workload. But when UAC prompt popping up, it doesn't work correctly. So I want to find a way to know if Windows is currently asking for UAC privilege and waiting for user's action. Not my application trying to obtain admin privilege.

I'll be grateful if you can help me with further information. Thank you.

0 Votes 0 ·

Hi,
Thank you for your reply.
As far as I know, it is related to change Mainfest file. For the UAC prompt about some application, I always use RunAsInvoker to bypass UAC without disable UAC completely.
http://woshub.com/how-to-disable-uac-for-specific-applications/
Some information about RunAsInvoker.

https://devblogs.microsoft.com/oldnewthing/20161117-00/?p=94735
Also as Castorix31 said, change (Mnifest with requireAdministrator) is worth a try.
Best Regards,
Carl

0 Votes 0 ·
Castorix31 avatar image
0 Votes"
Castorix31 answered

You can use SetWinEventHook with EVENT_SYSTEM_DESKTOPSWITCH (UAC, by default, uses the Secure Desktop)
and test if the process consent.exe is running
(tested on Windows 10, as Admin (Manifest with requireAdministrator) to detect consent.exe)





5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.