We i was looking for a similar function but unfortunately u dont have one... you still have to do with ExitWindowsEx... found it on one of the forums...
Using PInvoke to AdjustTokenPrivileges and ExitWindowsEx:
// ==========================================================
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack=1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}
==========================================================
using System.Management;
using System.Runtime.InteropServices;
ManagementPath path = new ManagementPath( );
path.Server = "yourpcname";
path.NamespacePath = @"root\CIMV2";
// See Boot.ini for OS identification, System dir and HD system partition.
path.RelativePath = @"Win32_OperatingSystem.Name=""Microsoft Windows 2000
Professional|C:\\WINNT|\\Device\\Harddisk0\\Partition1""";
ManagementObject o = new ManagementObject(path);
ManagementBaseObject inParams = null;
bool EnablePrivileges = o.Scope.Options.EnablePrivileges;
o.Scope.Options.EnablePrivileges = true;
ManagementBaseObject outParams = o.InvokeMethod("Shutdown", inParams, null);
o.Scope.Options.EnablePrivileges = EnablePrivileges;
// =========================================================
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.