1

Requested registry access is not allowed I want to access Remote Pc's Registry but it cant allow me to do so.

Below is my code

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"); This Is Working

but

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

this code show's me this error.

1
  • were you able to figure this out? I'm having this exact issue. Commented Sep 19, 2022 at 22:40

1 Answer 1

1

If anyone is wondering.

Was able to solve the issue by granting permissions to the following area:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurePipeServers\winreg 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.