Requesting Administrator privileges during runtime
Question
How do I request Administrator privileges during runtime so the user is given the prompt to allow or disallow it?
Solution
This information is written in the exe file manifest. You must use the requestedExecutionLevel
field (but not sure about that - try setting it to highestAvailable
and see if it does what you need). See for example here for more information (somewhat older article but still valid): http://blogs.msdn.com/b/cjacks/archive/2006/09/08/exploring-manifests-part-2-default-namespaces-and-uac-manifests-in-windows-vista.aspx
There are tools in Visual Studio which allow you to embed your own manifest or even just edit it. Also there is a tool written in Perl ( http://metacpan.org/pod/Win32::Exe::Manifest ).
EDIT: see this article for more info: http://www.codeproject.com/Articles/66259/Requesting-Admin-Approval-at-Application-Start.aspx
OTHER TIPS
if you want it in response to a button (eg, like 'show processes for all users' in task manager), you have to resart your app using the following method
ShellExecute(0,L"runas",exepath,0,0,SW_SHOWNORMAL);