Home > Software engineering >  c# Registry can't open Subkey with {}
c# Registry can't open Subkey with {}

Time:03-14

Here is my code

RegistryKey = regsohr;
regsohr = Registry.LocalMachine.OpenSubKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}");
sw.WriteLine(regsohr.GetValue("Path"));

It can't get into {DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}. But when I delete that line everything works fine. Anyone has any ideas why it can't open this SubKey? I will appreciate any help.

CodePudding user response:

Try this , for example i put it in a Label to check if it works

{
string readValue;
readValue = My.Computer.Registry.GetValue
 (@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache", "Tasks",Nothing);
Label6.Text = readValue;

}

CodePudding user response:

My bad. I have messed up with "HKEY_LOCAL_MACHINE".

regsohr = Registry.LocalMachine.OpenSubKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}");

Fixed it

regsohr = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}");
  •  Tags:  
  • c#
  • Related