不允许请求的远程注册表访问

时间:2019-09-04 10:49:29

标签: c# permissions registry remote-registry

不允许请求的注册表访问 我想访问远程PC的注册表,但它不允许我这样做。

下面是我的代码

private static void CheckRemoteRegistry()
 {

try {

    string serverName = "DESKTOP-2ME3g20M";

    NetworkShare share = new
    NetworkShare(serverName, "C$", "ARIgTEAM", "02123541");

    share.Connect();

    String ProductName = string.Empty;
    String InstanceName = string.Empty;
    RegistryKey key;
    RegistryKey key2;

    RegistryKey Remotekey = 
            RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, serverName, RegistryView.Registry64);

    if (Remotekey != null) 
                   {
        key = Remotekey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");

        key2 = Remotekey.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL");

        if (key != null) 
                  {
            ProductName = key.GetValue("ProductName").ToString();
            InstanceName = key.GetValue("MSSQLSERVER").ToString();
        }
    }
    share.Disconnect();
}
catch(Exception ex) {
    throw new Exception(ex.Message);
}
}

key = Remotekey.OpenSubKey(@“ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion”); 这正在工作

但是

key2 = Remotekey.OpenSubKey(@“ SOFTWARE \ Microsoft \ Microsoft SQL Server \ Instance Names \ SQL”);

此代码向我显示此错误。

0 个答案:

没有答案