Can't access remote registry "HKEY_LOCAL_MACHINE" by using "RegistryKey.OpenRemoteBaseKey"


  • Hi,

    I'm trying to use RegistryKey.OpenRemoteBaseKey" to access remote registry.  blocked by a werid problem.

    my machine and remote machine(name "myRemote") are in a same domain. And my account is in administrator group of remote machine.
    On remote machine, I create a key "HKEY_LOCAL_MACHINE\SOFTWARE\test\V1.0" in which a string value "build" with "1.0"
    Then I want to use Code to access this key.


    RegistryKey regKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "myRemote");
    RegistryKey dsRegKey = regKey.OpenSubKey(@"SOFTWARE\test\V1.0");
    string version = dsRegKey.GetValue("Build").ToString();


        dsRegKey is null, get exception when GetValue("Build")

    Other Contexts:
               1.   If I create the key under "HKEY_CURRENT_USER", and RDC to the remote machine with my account, then all is OK. I can get the version "1.0".
               2.   If I create the key under "HKEY_CURRENT_USER", but let the remote machine logged off, I still get the null result.
               3.   I also try to add the path "Software\test\V1.0" into "winreg"( AllowedExactPaths and AllowedPaths) , but still can't access the key under HKEY_LOCAL_MACHINE.
               4.   And I also try to access remote path "SOFTWARE\Microsoft\Windows NT\CurrentVersion", I can get the "ProductName"information. But If I change the "ProductName"by hand, access it again by code, still get old productname.
              How can I access remote registry "HKEY_LOCAL_MACHINE" freely?

    Sorry for so long description.
    Thanks in advance!

    Wednesday, December 09, 2009 8:36 AM

All replies