Next & Previous

Run a Windows app as admin, always, using the registry

Before Windows 8 you could go into the Properties of an exe and tick “Run as administrator”. Since then, you have to use the Troubleshoot Compatibility wizard. But, the wizard can be disabled by local/group policy. If so, you can directly set the “AppCompatFlags” values in the Windows registry.

  1. Find out the path of the exe you want to effect. Not the shortcut (lnk) to it - the program itself!
  2. Open registry editor (Win + R regedit)
  3. Navigate to Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
  4. Add a ‘String Value’ where the Name is the full path of the exe, and the Value is ^ RUNASADMIN

My final registry values for Visual Studio 2019 and 2022 (Enterprise) look like this:

The Registry Editor showing the added key-values for Visual Studio 2019 and 2022

Name                                                                                  | Type    | Data
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe | REG_SZ  | ^ RUNASADMIN
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\devenv.exe       | REG_SZ  | ^ RUNASADMIN

Hope it helps!