使用RemoteRegistry编写注册表 [英] Write Registry using RemoteRegistry
本文介绍了使用RemoteRegistry编写注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道如何在C#和ASP.Net中从服务器到客户端计算机编写RemoteRegistry的代码吗?
很难在Google中找到代码.请帮帮我.
我有代码,但仅用于从服务器读取注册表.
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();
}
谢谢!
Thanks!
推荐答案
您应该可以使用Powershell做到这一点.以下是运行Powershell脚本的方法:如何从C#运行PowerShell脚本 [ ^ ].请参阅如何从C#运行PowerShell脚本 [ ^ ]供使用使用powershell编写远程注册表.
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.
这篇关于使用RemoteRegistry编写注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文