开发者

Using RegistryKey, RegistrySecurity and RegistryAccessRule to repair bad registry settings on Windows XP

开发者 https://www.devze.com 2023-01-28 12:54 出处:网络
I have a C# appl开发者_运维问答ication that I am writing that will go repair broken registry keys across the organization.I am trying to use the three classes of RegistryKey, RegistrySecurity and Regi

I have a C# appl开发者_运维问答ication that I am writing that will go repair broken registry keys across the organization. I am trying to use the three classes of RegistryKey, RegistrySecurity and RegistryAccessRule and when I try to use them I get a "Requested registry access is not allowed.". I have searched this extensively and cannot find a good solution.

The key's I am trying to fix, have no permissions on them (see screenshot below). They are blank and have no inheritable settings. This doesn't allow me to fix them with my app as I have no permissions, but I can change the permissions with the user I run this application as if I open regedit. So I know I can add permissions to broken machines by manual means with this user, but for some reason my application no matter how hard I tell it to elevate itself cannot get the permissions.

Things I have tried:

  1. On Windows 7 it works when you run the application with UAC, right click run as administrator. I would like to duplicate being able to do this on Windows XP with the same code.
  2. I have created a manifest using level "highestAvailable" and also trying "requireAdministrator".
  3. I have also tried using "System.Security.Permissions.RegistryPermission" assert which apparently will bring higher level of permissions to run as well.
  4. I am not running this from a network share, although I have tried both local and network to see what security zone it would run from matters.

You can see what the permissions look like below: http://i.stack.imgur.com/0c99s.jpg

Any help is appreciated!


You could try impersonating an administrator account from within your code, using P/Invoke to call the necessary api's like this person did to create an account impersonation class:

Impersonator Class c#

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号