Take the 2-minute tour ×

For a while now the installer for my program has used the below code to make my app run with administer privileges. But it seems to have no affect under Windows 7. In Vista it worked beautifully. If I right click the shortcut and tell it to run as Administer, the program will start fine. But by using the below, code it should be made to run the program that way all the time. It doesn't anymore. Does anyone know if Win 7 still uses this key? UAC is also on by the way.

Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows NT\
CurrentVersion\AppCompatFlags\Layers", "C:\App\app.exe", "RUNASADMIN");


share|improve this question
add comment

4 Answers

up vote 5 down vote accepted

I am using Windows 7 and I can see such keys. However, I don't think that's a proper way to configure your application and installer.

My recommendation is that you distribute a manifest file along with your application (app.exe). The manifest file can be even embedded in the executable easily if you are using Visual Studio 2008. Then in the manifest file you can require administrator rights.




share|improve this answer
Thanks lextm. I didn't know a manifest file could be made for exe files I didn't create. Or that they didn't have to be embedded either. Thanks for the links. –  JimDel Nov 13 '09 at 19:24
@JimDel: All those links appear to relate to embedding the manifest. Where did you see how I'd do it "for exe files that I didn't create?" –  Pete Feb 7 at 19:04
add comment

I have your same problem.

In my Windows 7 the value of "RUNASADMIN" is placed in the key:

[HKEY_USERS \ S-1-5-21-3280352481-4073337744-872459336-1001 \ Software \ Microsoft \ Windows NT \ CurrentVersion \ AppCompatFlags \ Layers]

I don't think is valid for all PC. Let me know if it solves the problemw. I am interested in the problem.

Bye Leo

share|improve this answer
Thanks Leo, Ill look into that. –  JimDel Dec 11 '09 at 13:49
add comment

in win7 , RUNASADMIN IS PLACED IN KEY : when HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers using install shield 5.1 , the values are copied to the appcpmctflgsin wow6432node and exe actualy falis to run as admin.

share|improve this answer
add comment

This answer by RobeN works "for an exe file I didn't create," which you expressed as an interest in your comment on Lex Li's answer. It uses your original registry idea.

Two possibly relevant differences:

  1. With a 32-bit OS, I need not worry about the Wow6432Node (a concern mentioned by "uss")
  2. By using HKLM instead of HKCU, I need not worry about which user is executing the application (a concern mentioned by Leo).
share|improve this answer
add comment

Your Answer


