Rabir
Rabir

Reputation: 59

How to get system privilege

I have a C# program that require SeSystemEnvironmentPrivilege to access the UEFI NVRAM.

I found a really long code, that uses Win32 API to get the privilege, but is there a .NET version to get it? In process class, or somewhere else?

Upvotes: 4

Views: 1024

Answers (1)

Daniel
Daniel

Reputation: 143

If it is really necessary you can use the AdjustTokenPrivileges function. Something like this:

 [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);

You can get more info here:

Upvotes: 4

Related Questions