Click here to Skip to main content
15,350,244 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);

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
Prasad Khandekar 4-Jun-13 8:58am
Is it a local machine or remote machine? Also have a look at this article ( Also check this (

1 solution


I think below url will help to you.[^]

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