Process updateProcess = new Process(); //updateProcess.StartInfo.ErrorDialog = false; updateProcess.StartInfo.UseShellExecute = false; updateProcess.StartInfo.RedirectStandardOutput = true;
updateProcess.StartInfo.UserName = sUsername; SecureString password = new SecureString(); for (int i = 0; i < sPassword.Length; i++) { password.AppendChar(sPassword[i]); }
string sUsername = "user";
string sPassword = "123";
Process updateProcess = new Process();
//updateProcess.StartInfo.ErrorDialog = false;
updateProcess.StartInfo.UseShellExecute = false;
updateProcess.StartInfo.RedirectStandardOutput = true;
updateProcess.StartInfo.UserName = sUsername;
SecureString password = new SecureString();
for (int i = 0; i < sPassword.Length; i++)
{
password.AppendChar(sPassword[i]);
}
updateProcess.StartInfo.Password = password;
updateProcess.StartInfo.FileName = @"d:\test\update\update.bat";
updateProcess.StartInfo.WorkingDirectory = @"d:\test\update";
updateProcess.Start();
密码获取不了,得自己设定