【问题标题】:How to get system privilege如何获得系统权限
【发布时间】:2016-01-25 14:11:27
【问题描述】:

我有一个需要SeSystemEnvironmentPrivilege 才能访问UEFI NVRAM 的C# 程序。

我发现了一个很长的代码,它使用Win32 API 来获取特权,但是有没有.NET 版本来获取它?在进程类中,还是在其他地方?

【问题讨论】:

  • 我不知道它是否会起作用,所以作为评论发布,但尝试使用PsExec-s -i 开关,它将以系统用户身份运行交互式程序。 PsExec.exe -s -i YourApp.exe

标签: c# system uefi privilege


【解决方案1】:

如果确实需要,您可以使用 AdjustTokenPrivileges 功能。 像这样的:

 [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
    internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
    ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);

您可以在此处获取更多信息:

【讨论】:

    猜你喜欢
    • 2013-06-17
    • 1970-01-01
    • 1970-01-01
    • 2012-02-22
    • 2013-11-17
    • 2012-07-12
    • 2020-08-06
    • 2012-04-15
    • 2021-01-22
    相关资源
    最近更新 更多