public static extern bool CreateProcessWithTokenW( IntPtr hToken, DInvoke.Win32.Kernel32.LogonFlags dwLogonFlags, string lpApplicationName, string lpCommandLine, DInvoke.Win32.Kernel32.CreationFlags dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, [In] ref DInvoke.Win32.WinNT.StartupInfo lpStartupInfo, out DInvoke.Win32.Kernel32.ProcessInformation lpProcessInformation);
public static extern bool CreateProcessWithLogonW( string userName, string domain, string password, DInvoke.Win32.Kernel32.LogonFlags logonFlags, string applicationName, string commandLine, DInvoke.Win32.Kernel32.CreationFlags creationFlags, uint environment, string currentDirectory, ref DInvoke.Win32.WinNT.StartupInfo startupInfo, out DInvoke.Win32.Kernel32.ProcessInformation processInformation);
public static extern bool CreateProcessAsUserW( IntPtr hToken, string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, bool bInheritHandles, DInvoke.Win32.Kernel32.CreationFlags dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref DInvoke.Win32.WinNT.StartupInfo lpStartupInfo, out DInvoke.Win32.Kernel32.ProcessInformation lpProcessInformation);
public static void DetermineImpersonationMethod(IntPtr token, DInvoke.Win32.Kernel32.LogonFlags l, DInvoke.Win32.WinNT.StartupInfo startupInfo, out DInvoke.Win32.Kernel32.ProcessInformation processInfo) { if (CreateProcessAsUserW(token, null, @"c:\windows\system32\cmd.exe /Q /C hostname && exit", IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, null, ref startupInfo, out processInfo)) { TokenManager._method = 1; } else if (CreateProcessWithTokenW(token, l, null, @"c:\windows\system32\cmd.exe /Q /C hostname && exit", 0, IntPtr.Zero, null, ref startupInfo, out processInfo)) { TokenManager._method = 2; } }