Hi all,

I am trying to develop a C# application that will search the registry
of a Remote Computer and read the value that was found in the key.

I have got some code which I thought it would work for what I want to
achieve, however, it is always searching the computer locally with a
network. For example, if I want to search a remote computer the
computer is called xp_registry which I have put into the code and the
computer the program is running on is called MyLocalPC.

When I debug the program it always seems to search for \\MyLocalPC
\.... instead of \\Xp_Registry\....

Below is the code that I am using, which I believe should do what I
want it to do.

private void btnScanRegistry_Click(object sender, EventArgs e)
        {

                ConnectionOptions oConn = new ConnectionOptions();
                //oConn.Username = "My_Local_User";
                //oConn.Password = "MyPA";
                string computername = "\\\\Hello";

                ManagementScope scope = new ManagementScope("\\\
\Hello", oConn);
                scope.Connect();
                ManagementClass registry = new ManagementClass(scope,
new ManagementPath("StdRegProv"), null);
                ManagementBaseObject inParams =
registry.GetMethodParameters("GetStringValue");
                inParams["sSubKeyName"] = "SOFTWARE\\Microsoft\
\.NetFramework";
                inParams["sValueName"] = "InstallRoot";
                ManagementBaseObject outParams = registry.InvokeMethod
("GetStringValue", inParams, null);

               //Console.WriteLine(outParams["sValue"].ToString());
                MessageBox.Show("Registry Key: " + outParams
["sValue"].ToString());
        }

Thank you for your help in this matter.

Reply via email to