How to prevent uninstaller elevating for Standard Windows 10 user?
We have an x86 Win32 desktop application. When the installer is run by a Standard (non-Admin) user, we avoid elevating and/or showing a UAC prompt and install under C:\Users\username\AppData\Roaming\...
instead of the common Program Files
directory.
On Windows 10, when our uninstaller is launched from Control Panel -> Programs -> Programs and Features
, no UAC prompt is shown and the uninstaller runs without elevating. This is the desired behaviour. When the same uninstaller is launched from Start -> Settings -> System -> Apps & features
, a UAC prompt is shown.
(The same behaviour can be seen in the Opera browser installer/uninstaller. I tested v35.0.2066.37.)
Why does the same uninstaller behave differently when launched from Apps & features
versus Programs and Features
?
How can the UAC prompt be avoided when the uninstaller is launched from Apps & features?
The manifest of our uninstaller includes this:
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" />
</requestedPrivileges>
</security>
</trustInfo>
I tried changing the requestedExecutionLevel
, and also tried removing trustInfo
completely, but there was no change in behaviour either way.
Tested on Windows 10 version 1511 build 10586.104.
Edit: Just to clarify, the case I'm trying to handle is where the user has a Standard account and does not know the password of an Admin account. If they see a UAC prompt when they try to uninstall, they have no choice but to cancel it, and our uninstaller does not get run.
This is a bug in "Apps & features" as far as I know. The WiX people have closed this issue as a Windows bug and I assume they have notified the correct people @ Microsoft. The behavior is still the same in Insider build 15042 though so it is probably not going to get fixed in time for the Creators Update.
There is no workaround you can use if the standard user cannot elevate.
If they can elevate then you can use the re-spawn workaround posted in the comments or manually load the user profile and call RegOverridePredefKey
but they are both ugly hacks (IMHO).