指定用户名和密码启动指定文件
指定用户名和密码启动指定文件
public Process RunExe(string filePath,string user="",string pwd="", string argument = "") { Process p = new Process(); if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(pwd)) { p.StartInfo.UserName = user; p.StartInfo.Password = getSecureString(pwd); //Process.Start(filePath, user, pwd); } p.StartInfo.FileName = filePath; p.StartInfo.Arguments = argument; p.StartInfo.UseShellExecute = false; p.Start(); return p; } public SecureString getSecureString(string pwd) { SecureString securePwd = new SecureString(); for (var i = 0; i < pwd.Length; i++) { securePwd.AppendChar(pwd[i]); } return securePwd; }