Run Windows 8 Application as Administrator by Default

If you are tired of opening a command prompt while in a user account with Administrator privileges only to find out that you are denied access to it, here’s the solution.

The workaround is a small registry hack. All you need to do is add your application’s full path to the following path in Registry under Current User Key:

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

For people who don’t want their computer’s registry directly, install Windows 8 Admin righter.

You can also use this code:

 var key = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers");
if (key != null)
{
     var existingValue = key.GetValue("Full Application Path");
     if (existingValue == null)
        {
          key.SetValue("Full Application Path", "^ RUNASADMIN", RegistryValueKind.String);
          key.Close();
          }
         }
}


Read the rest of the instructions here: http://www.codeproject.com/Tips/795876/Run-Windows-Applications-as-Administrator-by-Defau

 

Leave a Reply

Your email address will not be published. Required fields are marked *