Why am I receiving the Error Code 740 - “The requested operation requires elevation” when launching/starting an Application

Sometimes CreateProcess(), CreateProcessAsUser(), CreateProcessWithTokenW() or CreateProcessWithLogonW() may fail with the error code 740 or “The requested operation requires elevation”. 

What does this mean and how do you resolve the issue?  

On Windows VISTA, we introduced User Access Control (UAC), the idea is to force users to NOT run as an Administrator.  If an application required Administrator rights and privileges, a user would go through UAC to elevate themselves to an Administrator.   If the user was already a member of the Administrators group, UAC would make them a true Administrator (also known as an Elevated User).  An application could mark itself via a manifest file (See requestedExecutionLevel) to indicate to Windows on whether the user is required to be an Administrator.

The process of determining whether an application needs to be elevated via UAC happens at the time the application is started by a user.  From the programming perspective, there are many Win32 APIs available to start an application.  (Note, .NET and WMI internally use the Win32 APIs as well) such as:

Unfortunately, none of these Win32 APIs can deal with an application marked with a manifest.  If these APIs encounter a manifested application, they will fail with the error code 740 or “The requested operation requires elevation”.

If you are wondering how Windows launches a manifested application, it is internally calling ShellExecute(), ShellExecuteEx().  So if you have an application which you need to launch, you should use ShellExecute() to start the application.  If you are using the .NET Process Class, to launch an application make sure that the UseShellExecute property in the ProcessStatInfo is set to TRUE.