Recently I was developing an application that required administrator level access on machine to do certain task.
UAC is a feature of Windows Vista and 7 designed to prevent unauthorized changes to your computer. By default, even an administrator account in modern versions of Windows does not have full access to modify system settings and install programs. Thus, if you try to install a program or change critical settings, you may see your desktop fade and show only a prompt window asking if you’re sure you want to do this. This ensures secure desktop, designed to prevent a program from automatically approving itself.
In case you are using standard (non-admin) account Windows will ask you to grant permission using admin account. The way to do this with .NET applications is to add a New Item of type Application Manifest File:
Followed by tweaking the Application Manifest file reflect that application would need Admin Privileges (Line 14). Details about what uiAccess is can be found here.
Running this application then would ask you for privileges as expected:
For C++ applications specify linker option
/MANIFESTUAC:"level='requireAdministrator' uiAccess='false' and the result should be same, or you can specify it in linker property pages:
Well, that’s all for now..
- What is User Account Control (windows.microsoft.com)
- /MANIFESTUAC (msdn.microsoft.com)
- Understanding User Account Control (technet.microsoft.com)
- How to Enable/Disable Secure Desktop (microsoft.com)
- How does Secure Desktop Work (stackexchange.com)