Wednesday, August 5, 2009

Force Elavation By Code - Windows Vista & 7

If you want to force your application to run in elavated mode in Windows Vista or Windows 7, here's a quick guid on how to do it:

There's a Registry Key called:

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers


Under this key, there's a value for each applications on your computer configured
either to run in compatability mode (WINXP or other) or as administrator (using elavation).

In order to add your application to this list, you should do the following:
1. Create a new REG_SZ (string) Value named after your full application path, i.e:

C:\Program Files\Your App\App.exe


2. Edit the Value you just created with the following data:

RUNASADMIN


3. If you want to force your application to run not only in elavation, but in XP SP3 compatability mode, update your Value's data to the following:

WINXPSP3 RUNASADMIN


Note: After creating this Registry Value, you must restart your application.

And... That's it!