title: C# delete registry key access denied
body: <p>I am attempting to delete the USBSTOR registry key with the following code under an administrator command prompt.</p>
  
  <pre><code>void DeleteRegistryKeys()
  {
      string keyOne = @"SYSTEM\CurrentControlSet\Enum\";
      using (RegistryKey key = Registry.LocalMachine.OpenSubKey(keyOne, true))
      {
          if(key != null)
          {
              key.DeleteSubKeyTree("USB");
              key.DeleteSubKeyTree("USBSTOR");
          }
  
      }
  }
  </code></pre>
  
  <p>I am getting a System.Security.SecurityException: Requested Registry Access is not allowed. Does anyone know a work around for this?</p>
  
  <p>I attempted to run as admin but that does not work. 
  I have added an app.manifest file that has </p>
  
  <pre><code>&lt;requestedExecutionLevel level="requireAdministrator" uiAccess="false" /&gt;
  </code></pre>
  
  <p>But that does not seem to help the program run either.</p>