With the evolution of Windows, the security requrements has been also risen up. In Windows 10 all applications are run under a lowered user account, which has no access to system folders, system registry entries and so on. The app is limited to something like a sandbox. But what to do if you need to acces to system files and registry keys? You need to run your application as a computer Administrator. This is done through the Windows process called "Elevation". How to run Windows Application as elevated or Administrator account? You will need to add a special entry in your .manifest file when you build your application. A Manifest file is a special sattelite file for your .exe that tells the system how to treat your program. If you don't have a .manifest file, you will need to create one. Also, your file should be linked as Embedded Manifest only. Side-by-side manifests are not supported for elevation.
All the tricks are done by putting the following line in your .manifest file:
<requestedexecutionlevel level="requireAdministrator" uiaccess="true" />
The sample .mainfest file is provided below. Please note that exact name and processor architecture can be different for your program.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity version="22.214.171.124" processorArchitecture="X86" name="IsUserAdmin" type="win32"/> <description>Description of the application</description> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedPrivileges> <requestedExecutionLevel level="requireAdministrator" uiAccess="true"/> </requestedPrivileges> </security> </trustInfo> </assembly>
Futher reading may be found here: MSDN