0

Basically, I have a key called "Manufacturer" in my registry under the path provided in the code.

I want to change the value assigned to that key, which should be simple from what I have found in my research

Problem

When I check regedit, it seems the keys were not altered at all.

Its runs fine, no errors. It actually prints my full 'Try' as if it succeeded.

Also when I try the '.GetValue()' method, it returns the value I assigned as if the program worked.

EDIT

I have been informed that the program defaults to a different path than what I have provided. (Thanks)

I do not know how to prevent this though...

//Here is my code:

namespace OEMInfo
{
    class Program
    {
        static void Main(string[] args)
        {
            String OEM = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\OEMInformation\\";

            try
            {
                RegistryKey OEMKey = Registry.LocalMachine.OpenSubKey(OEM, true);
                OEMKey.SetValue("Manufacturer", "TEST");
                Console.WriteLine("The registry key has been switched\n-----------------------------------------");
                Console.WriteLine("Press ENTER to continue.");
                Console.ReadLine();
            }
            catch
            {
                Console.WriteLine("There was an error switching the registry key!\n-----------------------------------------");
                Console.WriteLine("Press ENTER to continue.");
                Console.ReadLine();
            }
        }
    }
}

NOTE: I am a newbie, so please bear with me.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 1
    Have a look in `HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\OEMInformation` - I bet you're running a 32-bit app and it's getting silently redirected to that key. – Matthew Watson Aug 25 '15 at 15:17
  • Wowie, that was the issue. So how would I redirect it to the correct path? Would I have to reinstall the application with the proper architecture? – Cheesus Crust Aug 25 '15 at 15:20
  • Don't you also need to run the program as an admin to be able to edit Registry? – Filip Vondrášek Aug 25 '15 at 15:21
  • If I did not run as administrator, I would of got an error. Thanks for the insight though. – Cheesus Crust Aug 25 '15 at 15:22
  • 1
    Have a look at [this answer](http://stackoverflow.com/a/13729137/106159) which is similar (just a different hive; you can use the same solution, which is to use `RegistryView.Registry64`) – Matthew Watson Aug 25 '15 at 15:32
  • Thanks a lot for the help. Really appreciate it. – Cheesus Crust Aug 25 '15 at 15:45

0 Answers0