Run new process as user interacting with UI

I have a GUI process that is running as nt authoritysystem. I'd like to launch another process (preferably via Process class) as the user that is interacting with the GUI process. If I just call Process.Start the new process will also run as nt authoritysystem but I want it to be domainuser.

Edit: for clarification, I don't have the current user's username or password. I just want to run the process as though the user was starting it themselves without having to ask for username/password.


使用具有有效凭据的StartInfo属性。

Process proc = new Process();

proc.StartInfo.Domain = "YourDomain";
proc.StartInfo.UserName = "Username";
proc.StartInfo.Password = "YourPassword";

你可以这样做:

Process proc = new System.Diagnostics.Process();
System.Security.SecureString ssPwd = new System.Security.SecureString();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName = "C:/YourPath/YourProcess.exe";
proc.StartInfo.Arguments = "Args"; //Arguments if any, otherwise delete this line
proc.StartInfo.Domain = "domainname";
proc.StartInfo.UserName = "username";
proc.StartInfo.Password = "password";
proc.Start();

var psi = new ProcessStartInfo(); 
psi.Verb = "runas"; 
psi.FileName = "notepad.exe";
Process.Start(psi);
链接地址: http://www.djcxy.com/p/61114.html

上一篇: C#进程作为不同的用户不工作而运行

下一篇: 以用户与UI交互的方式运行新进程