Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 372119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:10:47+00:00 2026-05-12T14:10:47+00:00

I am trying to modify a registry key that I have been told controls

  • 0

I am trying to modify a registry key that I have been told controls whether write-caching is enabled on particular hard drives. The key should be: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\IDE\<DiskName>\<SerialNo>\Device Parameters\Disk\UserWriteCacheSetting

However I keep having problems when trying to create this key (as it doesn’t exist by default). If I try to open up the ...\Device Parameters\Disk\ with write access I get a SecurityException error; “Requested registry access is not allowed”. Now I have added the <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> flag to my manifest file so as to ensure I have admin access, but I’m still not having any luck.

Any ideas would be great!

    static void Main(string[] args)
    {
        RegistryKey myKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Enum\\IDE\\");

        foreach (string driveManafacturer in myKey.GetSubKeyNames())
        {
            RegistryKey driveKey = myKey.OpenSubKey(driveManafacturer);
            foreach (string driveID in driveKey.GetSubKeyNames())
            {
                RegistryKey driveIDKey = driveKey.OpenSubKey(driveID, true);
                string driveType = (string)driveIDKey.GetValue("Class");
                if (driveType == "DiskDrive")
                {
                    RegistryKey tempKey = driveIDKey.OpenSubKey("Device Parameters\\Disk\\", true);
                    if (tempKey == null)
                    {
                        tempKey = driveIDKey.CreateSubKey("Device Parameters\\Disk\\");
                        tempKey.SetValue("UserWriteCacheSetting", 0x0);
                    }
                }
            }
        }

        return;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:10:48+00:00Added an answer on May 12, 2026 at 2:10 pm

    EDIT: Removed the idea about partial trust … it turned out that it had nothing to do with the problem.

    I tried your code and got the same error – with some modifications it works:

    RegistryKey myKey = Registry.LocalMachine.OpenSubKey( "SYSTEM\\CurrentControlSet\\Enum\\IDE\\" );
    
    foreach( string driveManafacturer in myKey.GetSubKeyNames() )
    {
      RegistryKey driveKey = myKey.OpenSubKey( driveManafacturer );
    
      foreach( string driveID in driveKey.GetSubKeyNames() )
      {
        RegistryKey subKey = driveKey.OpenSubKey( driveID );
        string driveType = (string)subKey.GetValue( "Class" );
        if( driveType == "DiskDrive" )
        {
          RegistryKey tempKey = subKey.OpenSubKey( "Device Parameters", true );
          RegistryKey tempKey2 = tempKey.OpenSubKey( "Disk" );
          if( tempKey2 == null )
          {
            tempKey2 = tempKey.CreateSubKey( "Disk" );
            tempKey2.SetValue( "UserWriteCacheSetting", 0x0 );
          }
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a quick app to modify some registry keys. When I'm
I have been trying to modify the following code in JSP from here :
I am trying to modify a batch script that installs a simple script file
I'm trying to modify the following code so that it will return a Dictionary<int,int>
I'm trying to modify some code that returns results from the database. Currently the
Here is the regular expression that I am trying to modify: The client only
I am trying to modify the MethodParameter directly in the XAML. I do have
Im trying to modify the class below so that the scrolling text appears behind
I'm trying to modify my GreaseMonkey script from firing on window.onload to window.DOMContentLoaded, but
I'm trying to modify the class of an element if an ajax call based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.