删除顽固的注册表项

编程入门 行业动态 更新时间:2024-10-27 00:28:01
本文介绍了删除顽固的注册表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

说明

一个驱动程序在注册表中留下了混乱(即使我从系统中将其卸载).如果我检查安全设置,它将不会在组或用户名"中显示任何内容.当我检查所有者时,它仅显示无法显示当前所有者.".当我想删除注册表项时,我必须:

One driver left a mess in the registry (even when I uninstalled it from the system). If I check the security setting it will not display anything in "Group or user names". And when I check the owner it shows only "Unable to display current owner.". When I want to delete the registry keys I have to:

  • 取得所有权.

  • Take the ownership.

    添加组.

    删除密钥.

    问题在于每个注册表都有几个子项,我必须在每个项上重复该过程.继承权限选项在注册表编辑器中不起作用.是的,我正在管理员模式下运行注册表编辑器.

    The problem is that each registry has several sub keys and I have to repeat the process on each key. Inherit permission option will not work in Registry Editor. And yes, I am running Registry Editor in administrator mode.

    问题

    我想编写一个简单的C#代码,该代码将循环并删除所有键.我找到了一些代码示例,但就我而言,任何OpenSubKey调用都会因错误而失败: System.Security.SecurityException:不允许请求的注册表访问. 如果任何OpenSubKey函数调用失败,如何更改所有权?还有其他可用来声明所有权然后删除注册表项的命令吗?

    I wanted to write a simple C# code that would loop and delete all keys. I have found some code samples, but in my case any OpenSubKey call would fail with error: System.Security.SecurityException: Requested registry access is not allowed. How can I change the ownership if any call of OpenSubKey function would fail? Is there any other command where I can claim the ownership and then delete the registry key?

    感谢您的支持

    推荐答案

    就像您知道以管理员身份运行注册表编辑器一样,以确保您具有修改/删除注册表项的适当特权,您需要对您的C#应用​​程序执行相同的操作.

    Just as you knew to run the Registry Editor as an administrator in order to ensure that you would have the appropriate privileges to modify/delete registry keys, you need to do the same thing for your C# application.

    由于您忘记了执行此操作,因此会抛出System.Security.SecurityException作为提醒.如异常消息所述,您无权修改/删除注册表项.

    Because you forgot to do this, the System.Security.SecurityException is being thrown as a reminder. As the exception message says, you do not have the privileges to modify/delete the registry key(s).

    要解决此问题,必须使用管理特权执行C#应用程序.您可以手动执行此操作,也可以向您的应用程序添加清单,这将导致该清单自动要求管理权限.

    To solve the problem, you must execute your C# application with administrative privileges. You can either do this manually, or add a manifest to your application that will cause it to automatically demand administrative privileges.

  • 更多推荐

    删除顽固的注册表项

    本文发布于:2023-11-03 14:35:09,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1555376.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:顽固   注册表

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!