如何在 .NET 应用程序中按需提升和获取管理员权限?

发布于 2024-08-31 04:46:41 字数 139 浏览 4 评论 0原文

我有一个 .NET 应用程序,它以当前用户的默认权限运行,然后在某些时候我需要执行需要管理员权限的操作。

如何在 .NET 应用程序中按需获得管理员权限?

要求应用程序从一开始就以管理员权限运行是不合适的,因为可能不会调用此类操作。

I have an .NET application which is run with default rights as the current user, then at some point I need to perform an action which requires admin rights.

How can I get admin rights on-demand in a .NET application?

Requiring that the application is run with admin rights from the beginning is not appropriate as it may be that such action may not be called.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七颜 2024-09-07 04:46:42

我认为这是不可能的。解决这个问题的一种方法是将您的应用程序一分为二,一种用于不需要提升的所有操作,另一种用于需要提升的操作。
然后,您可以正常运行非提升的应用程序,但在需要时启动提升的应用程序。

I don't think this is possible. One way to get around it would be to split your application in two, one for all the operations that doesn't need elevation and one for the ones that do.
Then you run the non elevated app as normal but start up the elevated one when needed.

原野 2024-09-07 04:46:42

询问用户名/密码并模拟管理员用户。

Ask username/password and impersonate the admin user.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文