110,571
社区成员
发帖
与我相关
我的任务
分享
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.UseShellExecute = false;
startInfo.WorkingDirectory = Environment.CurrentDirectory;
startInfo.FileName = System.Configuration.ConfigurationManager.AppSettings["exeName"];
string username = null, pwd = null;
startInfo.Verb = "runas";
username = System.Configuration.ConfigurationManager.AppSettings["adminName"]; //admin2,管理员账号
pwd = System.Configuration.ConfigurationManager.AppSettings["adminPwd"];
SecureString pwds = new SecureString();
foreach (var c in pwd.ToCharArray())
{
pwds.AppendChar(c);
}
startInfo.UserName = username;
startInfo.Password = pwds;
System.Diagnostics.Process.Start(startInfo);