0
votes

VS2008 C# winforms with deployment project. I need to access registry to store settings. but to do that I need to add an external manifest to the project. Without the manifest included the application cannot access registry.

(is there another way?)

manifest as just one setting: requestedExecutionLevel level="requireAdministrator" uiAccess="false"

I made sure that assemblyIdentity version match the project name and version.

with manifest included all works well, BUT User access control keep popping up EVERY time I launch the application. Why does the UAC nor remember user clicked OK last time? I am happy with user clicking it once but not every time. What is required to charge this? thanks

1
This is normal of course. Use keys in HKCU instead of HKLM to avoid having to ask for elevation.Hans Passant
yes thanks that was the problem.Lambda

1 Answers

0
votes

Rather than marking your application as requireAdministrator, mark it as asInvoker.

Then for those limited places where you absolutely do require administrator access, relaunch a copy of your app using ShellExecute and the magical runas verb.

It will trigger UAC consent dialog and run your app as an administrator.