running as administrator

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:

Adding Application Manifest Item

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:

UAC Request for elevating permissions

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:

C++ Linker Manifest Options C++ Linker Command Line

Well, that’s all for now..

References:

  1. What is User Account Control (windows.microsoft.com)
  2. /MANIFESTUAC (msdn.microsoft.com)
  3. Understanding User Account Control (technet.microsoft.com)
  4. How to Enable/Disable Secure Desktop (microsoft.com)
  5. How does Secure Desktop Work (stackexchange.com)