none
C# Unable to read registry key - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Virtual Machine\Guest RRS feed

  • Question

  • I'm sure this is the incorrect forum, and please let me know where I should go if it is not.

    Platforms: Windows 8.1, Windows Server 2012 R2

      • We have many VM machines, and they get moved around to different hosts.

      • We want to be able to get the VM host for any given VM.

      • All of the issues below seem to revolve around some security issues.

      • I am able to run the following the VM, VM_HOST, and other machines, and get back the PhysicalHostName.

        reg query "\\<Server>\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Virtual Machine\Guest" /s

      • I’m wanting to get to the following key.

        "SOFTWARE\\Microsoft\\Virtual Machine\\Guest"

      • I have a simple C# registry walker, which is returning all of the keys and values under SOFTWARE\\Microsoft, however, I get back…

        UDRM

        UPnP Device Host

        Then it skips to returning Visual Studio key.

        It never return the Virtual Machine key.

      • I am unable to get this value regardless of where I run the code, the actual VM, the VM Host, and other servers.

      • I have given myself full access to the key, and also have tried each and all of the following combinations (from MSDN)



    RegistryPermission(RegistryPermissionAccess.AllAccess, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");



    RegistryPermission

    readPerm1 = newRegistryPermission(RegistryPermissionAccess.AllAccess, "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft");


    RegistryPermission

    readPerm2 = newRegistryPermission(PermissionState.Unrestricted);

                readPerm2.FromXml(readPerm1.ToXml());

               

    Console.WriteLine("Result of ToFromXml = "+ readPerm2.ToString() + "\n");


    Anyone have any ideas on what I’m missing?

    Thank You



    Richard Loba

    Thursday, May 21, 2015 7:18 PM

Answers

  • Hi Winnetka,

    >>I have given myself full access to the key, and also have tried each and all of the following combinations (from MSDN)

    Yes, I got that your code has set with Registrypermission. Have you try RegistrySecurity. It's documented here.

    Changing registry permission in c#?If that not work, I think you shouldn't only rely on .NET code access security for managing access control to the registry. Do you have the necessary permissions to read that key? I mean. Try to run as administrator and see it if opens.     

    And after some research, It may also related to whether your machine is 32bit or 64bit. 32-bit and 64-bit applications have different views of the registry.

    Please refer to the following threads for more detailed information.

    cannot write to the registry key

    OpenSubKey not working for Registry value I need

    Hope this help!

    Best regards,

    Kristin

               

              


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Saturday, May 23, 2015 4:37 AM