writing to registry access denied

This is a discussion on writing to registry access denied within the C# Programming forums, part of the General Programming Boards category; on windows tablet PCs, the registry key "HKLM\SOFTWARE\Microsoft\TabletTip\DisableInPl ace" contains a list of programs that do not allow a long ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    2,348

    writing to registry access denied

    on windows tablet PCs, the registry key "HKLM\SOFTWARE\Microsoft\TabletTip\DisableInPl ace" contains a list of programs that do not allow a long press to bring up an onscreen keyboard.

    the trouble I am having is that when I try to update entries in that key, I get an access denied error on windows 7. I am running the program as an administrator, and I have UAC turned off. There should be nothing preventing me from updating that registry key, but yet I cannot. what can I do to write to that key?

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,163
    Hard to tell without seeing your code. Are you sure you're requesting write access (e.g. key.OpenSubKey("SOFTWARE\\Microsoft\\TabletTip\\Di sableInPlace", true))?
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    2,348
    Quote Originally Posted by itsme86 View Post
    Hard to tell without seeing your code. Are you sure you're requesting write access (e.g. key.OpenSubKey("SOFTWARE\\Microsoft\\TabletTip\\Di sableInPlace", true))?
    yes. the code to open the key is as follows:

    Code:
    RegistryKey myKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft", true)
                                             .CreateSubKey("TabletTip")
                                             .CreateSubKey("DisableInPlace");
    and it actually throws an exception on CreateSubKey("TabletTip")

  4. #4
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    611
    It's probably due to
    Code:
    Security Info for MACHINE\software\microsoft\tablettip
    
    Owned by: NT SERVICE\TrustedInstaller
    
      ACCESS RIGHTS
    -----------------
    BUILTIN\Administrators has access 0x20019 and can:
            Read the Security Descriptor
    
            Enumerate Sub Keys
            Request Change Notifications
            Query Value
    
    BUILTIN\Administrators has access 0x80000000 to child objects and can:
            Request Generic Read Permissions
    Admins can't write to that key. CreateSubKey is trying to open it for some form of write access. If there's an OpenSubkey(), try that. Only the DisableInPlace key needs to be open for writing.
    Last edited by adeyblue; 11-21-2011 at 02:09 PM.

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    2,348
    Quote Originally Posted by adeyblue View Post
    Admins can't write to that key.
    that can't be true, because when I run regedit.exe, I can edit that key all day long. what's different about it when I do it programmatically?

  6. #6
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    611
    The difference is that you're editing the values of the DisableInPlace key (which has a different DACL that lets admins write to it), not the TabletTip key (which has the DACL above). Try and make a new subkey for TabletTip in regedit (a sibling for DisableInPlace, not a child of it). Unless you've manually changed the permissions, it'll fail.

    CreateSubkey-ing your way down the chain asks for write access all the way. You only need write access for the last leaf, not all the branches. This is the case whenever you write to the registry. Asking for more permissions than you need just sets yourself up for failure when the user doesn't actually have that level of security.

  7. #7
    Registered User
    Join Date
    Oct 2006
    Posts
    2,348
    there is the possibility that the TabletTip subkey doesn't already exist, and so therefore needs to be created. how do I work around this?

  8. #8
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    611
    Code:
    RegistryKey tabletTipKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\TabletTip");
    if(tabletTipKey == null)
    {
        tabletTipKey = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\TabletTip");
    }
    RegistryKey myKey = tabletTipKey.CreateSubKey("DisableInPlace");

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Access is denied when listen on a port
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-29-2008, 09:01 AM
  2. Access denied on adding another registry value
    By BobS0327 in forum Windows Programming
    Replies: 0
    Last Post: 01-09-2006, 07:10 PM
  3. c:\boot.ini access denied!
    By Bajanine in forum Tech Board
    Replies: 8
    Last Post: 11-17-2005, 10:52 AM
  4. access denied
    By laasunde in forum C++ Programming
    Replies: 4
    Last Post: 10-25-2002, 02:38 PM
  5. class member access denied
    By chiqui in forum C++ Programming
    Replies: 2
    Last Post: 05-27-2002, 02:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21