Click here to Skip to main content
15,916,280 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Anyone have the code on how to write in RemoteRegistry in C# and ASP.Net from server to client machine?

It's hard to find the code in google. Please help me.

I have the code but it's only for reading the registry from server.

public static string ConnectToRegistry (string servername)

string regKeyToGet, keyToRead;

ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = "admin";
oConn.Password = "pass";
ManagementScope scope = new ManagementScope(@"//" + servername + @"/root/default", oConn);
registry = new ManagementClass(scope, new ManagementPath("StdRegProv"), null);

// Returns a specific value for a specified key
ManagementBaseObject inParams = registry.GetMethodParameters("GetStringValue");
inParams["sSubKeyName"] = regKeyToGet;
inParams["sValueName"] = keyToRead;
ManagementBaseObject outParams = registry.InvokeMethod("GetStringValue", inParams, null);

return outParams["sValue"].ToString();



1 solution

You should be able to do it with Powershell. Here is how to run powershell scripts: How to run PowerShell scripts from C#[^]. See How to run PowerShell scripts from C#[^] for using powershell to write remote registry.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900