[英]Requested remote registry access is not allowed
不允许请求的注册表访问 我想访问 Remote 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");
这段代码向我展示了这个错误。
使用Sql获取所有键.Sql将提供所有键的信息。您可以找到查询
如果有人想知道。
能够通过授予以下区域的权限来解决该问题:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurePipeServers\winreg
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.