SecurityException when Accessing Registry as SYSTEM RRS feed

  • Question

  • Hi,

    I've been working on a C# project which makes a snapshot of the registry and tracks changes every once in a while.

    I am making use of the Registry.OpenSubKey method to recursively get all the keys and put them in a dictionary. From which, I realized that there were issues with regards to permissions of several registry entries.

    Thus, I decided to run the application under SYSTEM (not just right click "run as administrator"). There are less SecurityExceptions but they still do appear. 

    ERROR:System.Security.SecurityException: Requested registry access is not allowe
       at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)
       at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
       at RegistryChecker.RegistryLogic.RegProcessor.Read(RegistryKey root, IDiction
    ary`2 values) in c:\Users\mask\Documents\Visual Studio 2012\Projects\RegistryC
    hecker\RegistryChecker\RegistryLogic\RegProcessor.cs:line 89
    The Zone of the assembly that failed was:

    It would be nice if someone could let me know why this exception is still coming up - I am puzzled as SYSTEM should be the most privileged? Does it have to do with the app privileges? Thanks!


    returns "NT AUTHORITY/SYSTEM".

    The code that calls is as follows:

      foreach (var child in root.GetSubKeyNames())
                        using (var childKey = root.OpenSubKey(child,false))
                             //DO STUFF
                    catch (Exception e)
                        Console.WriteLine("ERROR:" + e);

    Thank you very much!

    • Edited by Brandon Lum Wednesday, July 24, 2013 9:12 PM
    • Moved by Caillen Thursday, July 25, 2013 1:49 AM
    Wednesday, July 24, 2013 9:09 PM


All replies