已经按这篇文章说的进行了尝试,但测试后发现没有效果
https://technet.microsoft.com/zh-cn/library/ff384148(v=ws.10).aspx
测试代码:
Process p = new Process();
p.StartInfo.FileName =@"F:\我的文档\Visual Studio 2015\Projects\ConsoleApplication1\ConsoleApplication2\bin\Debug\ConsoleApplication2.exe";
p.StartInfo.UserName = "testt";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
var pwd = new System.Security.SecureString();
"123456".All(x => { pwd.AppendChar(x); return true; });
p.StartInfo.Password = pwd;
p.Start();