This is unmanaged code, so you need to use P / Invoke (Platform Invoke), here is the function signature for CreateProcessWithTokenW() :
[DllImport("advapi32", SetLastError = true, CharSet = CharSet.Unicode)] public static extern bool CreateProcessWithTokenW( IntPtr hToken, LogonFlags dwLogonFlags, string lpApplicationName, string lpCommandLine, CreationFlags dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, [In] ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation);
You can use an enumeration like this to pass the LogonFlags parameter (to keep the .net feeling :)):
public enum LogonFlags { WithProfile = 1, NetCredentialsOnly }
Here is the listing for CreationFlags after the documentation available here :
public enum CreationFlags { DefaultErrorMode = 0x04000000, NewConsole = 0x00000010, NewProcessGroup = 0x00000200, SeparateWOWVDM = 0x00000800, Suspended = 0x00000004, UnicodeEnvironment = 0x00000400, ExtendedStartupInfoPresent = 0x00080000 }
Nasreddine
source share