0

Here's what I have so far, but it just keeps using the catch and the key is never deleted.

private void button7_Click(object sender, EventArgs e)
    {
        try
        {
               Microsoft.Win32.Registry.LocalMachine.DeleteSubKey(@"Software/Microsoft/Windows/CurrentVersion/Policies");
        }
        catch
        {
            MessageBox.Show("Restrictions already removed. Or there was an error.","Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

What is wrong with my code?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • not trying to delete the value. trying to delete the entire key. -- EDIT: okay and I have taken the backup thanks for the tip. – Braden Jensen Sep 15 '14 at 02:46
  • 2
    Does it throw any exceptions? Maybe you don't have administrator permission to do so! – Ghasem Sep 15 '14 at 03:07
  • Since you are in a `catch` there is an exception. What does the exception tell you? Tip: You can set the debugger to break when an exception is thrown: Debug > Exceptions... or Ctrl+D, E. – HABO Sep 15 '14 at 03:23
  • Ah, yes. The exception says the subkey does not exist. Now, is what I am trying to delete a KEY or SUBKEY? – Braden Jensen Sep 15 '14 at 05:16

0 Answers0