none
Problem to write access HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Video RRS feed

  • Question

  • First of all, I did search the entire forum but didn't find useful answer can solve my problem.

    Here is my development tools and test environment information.

    • Visual Studio 2013 with Update 3
    • Windows Form desktop application with .NET Framework v2.0
    • The language I am using is C#
    • I tested with both Windows 8.1 and Windows 7 and run into same problem

    I am a graphics driver engineer and want to develop some tools for internal usage. .NET Framework give me the fastest way to create a decent GUI tool and this is reason why I choose it.

    As I am working with graphics driver, I need update the keys under "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Video".

    However, I run into the problem with the following line of code,

    RegistryKey theVideoKey = Registry.LocalMachine.CreateSubKey(theKeyStr);

    The error message is:

    An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll

    Additional information: Access to the registry key 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Video\{????}\0000' is denied.

    I tried everything I think could be useful found on the forum, such as "run as Adminitrator" but it doesn't work. Please help.

    Monday, October 20, 2014 9:11 AM

Answers

  • Hello Zhengsan,

    >>Should I close this thread and start a new one?

    This is recommended so that if others read this thread, they would not feel confused.

    >>Now the question becomes how I can take over the owner and change access right of the specific registry key in .NET.

    In my opinion, this issue is more related with the windows client and suggest that you could post it to the more appropriate forum as the one mentioned in my last reply. I think there are not .net libraries could improve the “0000” permission.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Fred BaoModerator Wednesday, November 5, 2014 6:59 AM
    • Marked as answer by Zhengsan Wednesday, November 5, 2014 7:02 AM
    • Unmarked as answer by Zhengsan Wednesday, November 5, 2014 7:02 AM
    • Marked as answer by Zhengsan Wednesday, November 5, 2014 7:03 AM
    Wednesday, November 5, 2014 6:59 AM
    Moderator

All replies

  • run Process Monitor and create a path filter to only show access to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Video. What do you see?



    Visual C++ MVP

    Monday, October 20, 2014 2:07 PM
  • Here is the screen capture with Process Monitor when I try to run the app as Administrator.


    Monday, October 20, 2014 3:34 PM
  • Hello Zhengsan,

    >>I tried everything I think could be useful found on the forum, such as "run as Adminitrator" but it doesn't work. Please help.

    Being not sure if you have seen this link, I think this might be helpful, you could check it:

    http://stackoverflow.com/a/10151848

    It shows that you are most likely using User Account Control (UAC). This means that even if you are an administrator your access token doesn't have the necessary privileges to do things like creating registry keys in HKEY_LOCAL_MACHINE.

    You could follow steps in the link to check if you could create the sub key.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, October 21, 2014 3:02 AM
    Moderator
  • Hi Fred,

    Thanks for your information and thing changed a little bit after I tried lots of settings but it still doesn't go well as I expected.

    Now it works on Windows 8.1 if I run it as Adminitrator or include a UAC manifest. However, it still doesn't work on Windows 7 with the exactly same binary.

    The error message is

    Wednesday, October 22, 2014 4:14 AM
  • Hi Zhengsan,

    With the login account, could youcreate/modify the registry keys in HKEY_LOCAL_MACHINE by hand with the windows 7?

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 22, 2014 9:15 AM
    Moderator
  • Hi Fred,

    Yes I can create/modify the registry keys in HKEY_LOCAL_MACHINE if I run *regedit* from command line in Windows 7.

    Please be noted, I tried many Windows 8.1 and Windows 7 systems in office and all of them show same result that it works on Windows 8.1 but not on Windows 7.

    Wednesday, October 22, 2014 12:51 PM
  • Hello,

    I would try to make a test with similar environment with windows 7. This would take some time, and I would post back as soon as I get any result.

    Update:

    Under the windows 7, however, the program also creates the sub key to localmachine node successfully. Please check if the account is an elevated admin user since non-admin and unelevated admin users don't have rights to modify the HKEY_LOCAL_MACHINE key.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Fred BaoModerator Wednesday, October 29, 2014 7:48 AM Update after testing with windows 7.
    Thursday, October 23, 2014 8:32 AM
    Moderator
  • Hi Fred,

    Thanks very much for you helping but I am still sufferring from this issue.

    Is it possible you send me your EXE file so I can try it on my Windows 7, also Windows 8.1 as well?

    Please be noted, I chose .NET Framework 2.0.

    By the way, I tried on Windows XP today and it has same problem as Windows 7. Windows XP doesn't have UAC and I logged in as a user in Administor group so I am curious how this will happen.

    Should I send you my EXE as well?

    Thanks

    Zhengsan

    Wednesday, October 29, 2014 9:20 AM
  • Hello Zhengsan,

    >> Is it possible you send me your EXE file so I can try it on my Windows 7, also Windows 8.1 as well?

    This is the test code which runs with .NET Framework 2.0 and windows 7 and creates the registry key successfully, it actually is copied from MSDN:

    class Program
    
        {
    
            static void Main(string[] args)
    
            {
    
                RegistryKey test9999 = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Test9999");
    
                using (RegistryKey testName = test9999.CreateSubKey("TestName"), testSettings = test9999.CreateSubKey("TestSettings"))
    
                {
    
                    // Create data for the TestSettings subkey.
    
                    testSettings.SetValue("Language", "French");
    
                    testSettings.SetValue("Level", "Intermediate");
    
                    testSettings.SetValue("ID", 123);
    
                }
    
            }
    
    }
    

    >> Should I send you my EXE as well?

    You could upload your project to SkrDrive so that we can download it and test it.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 29, 2014 9:48 AM
    Moderator
  • Hi Fred,

    Sorry it takes a while for me to upload the project. The project was uploaded to SkyDrive and the link is http://1drv.ms/1t7vwH1. Please help to take a look. I double checked and the problem is still there.

    Thanks in advance!

    Zhengsan

    Tuesday, November 4, 2014 3:39 AM
  • Hello,

    Thanks for sharing the project with us. With it, I made a test and find I could reproduce this access denied exception. In my test, I create sub key step by step from the CurrentControlSet to the Guid node, all are ok until the ‘0000’ which throws the exception. Then I check the permission of this key and find there is only a user name “TrustedInstaller” have full control with this key and the administrator only has the Read permission, for solving the permission issue, you could find a solution in this discussion:

    https://social.technet.microsoft.com/Forums/windows/en-US/56fed319-a532-46a4-a384-fd795998c4a3/regedit-permissions-access-denied-or-error-while-deleting-key-even-as-admin

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, November 4, 2014 9:25 AM
    Moderator
  • Thanks Fred very much to find the root cause!

    Now the question becomes how I can take over the owner and change access right of the specific registry key in .NET.

    Should I close this thread and start a new one?

    Thanks

    Zhengsan

    Wednesday, November 5, 2014 4:08 AM
  • Hello Zhengsan,

    >>Should I close this thread and start a new one?

    This is recommended so that if others read this thread, they would not feel confused.

    >>Now the question becomes how I can take over the owner and change access right of the specific registry key in .NET.

    In my opinion, this issue is more related with the windows client and suggest that you could post it to the more appropriate forum as the one mentioned in my last reply. I think there are not .net libraries could improve the “0000” permission.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Fred BaoModerator Wednesday, November 5, 2014 6:59 AM
    • Marked as answer by Zhengsan Wednesday, November 5, 2014 7:02 AM
    • Unmarked as answer by Zhengsan Wednesday, November 5, 2014 7:02 AM
    • Marked as answer by Zhengsan Wednesday, November 5, 2014 7:03 AM
    Wednesday, November 5, 2014 6:59 AM
    Moderator