public static void StartProcessAsUser(string binary, string cmdline, string domain, string username, string password) { Structs.STARTUPINFO startupInfo = new Structs.STARTUPINFO(); Structs.LogonFlags lflags = new Structs.LogonFlags(); //UInt32 exitCode = 123456; Structs.PROCESS_INFORMATION processInfo = new Structs.PROCESS_INFORMATION(); String command = @"c:\windows\notepad.exe"; String currentDirectory = System.IO.Directory.GetCurrentDirectory(); WinAPI.CreateProcessWithLogonW(username, domain, password, lflags, command, command, (UInt32)0, (UInt32)0, currentDirectory, ref startupInfo, out processInfo); }
public static extern bool CreateProcessWithLogonW(String userName, String domain, String password, Structs.LogonFlags logonFlags, String applicationName, String commandLine, Structs.CreationFlags creationFlags, UInt32 environment, String currentDirectory, ref Structs.STARTUPINFO startupInfo, out Structs.PROCESS_INFORMATION processInformation);