Click here to Skip to main content
14,699,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to read the registry key by using WMI. I have tried with following code but i am unable to get the registry key value.

Can anyone help me regarding this problem.
ConnectionOptions oConn = new ConnectionOptions();
System.Management.ManagementScope scope = new System.Management.ManagementScope(@"\\" +hostname + @"\root\cimv2", oConn);

scope.Connect();
ManagementClass registry = new ManagementClass(scope, new ManagementPath("StdRegProv"), null);
ManagementBaseObject inParams = registry.GetMethodParameters("GetStringValue");
inParams["sSubKeyName"] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\.NETFramework";
inParams["sValueName"] = "InstallRoot";


ManagementBaseObject outParams = registry.InvokeMethod("GetStringValue", inParams, null);

if (outParams.Properties["sValue"].Value != null)
{
 output = outParams.Properties["sValue"].Value.ToString();

}

Note: i want to read the registry keys by using WMI only
Posted
Comments
Prasad Khandekar 4-Jun-13 8:58am
   
Is it a local machine or remote machine? Also have a look at this article (http://www.codeproject.com/Articles/18122/Howto-Almost-Everything-in-WMI-via-C-Part-1-Regist) Also check this (http://blogs.technet.com/b/tonyso/archive/2005/10/28/413236.aspx)

1 solution

Hi,

I think below url will help to you.


http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/30db8534-0a15-4ba7-9b55-7ab772633d68[^]

Thanks,
Suneel Kumar SVS.
   

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