【发布时间】:2011-01-23 01:41:55
【问题描述】:
我正在使用以下代码来触发 iexplore 进程。这是在一个简单的控制台应用程序中完成的。
public static void StartIExplorer()
{
var info = new ProcessStartInfo("iexplore");
info.UseShellExecute = false;
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
string password = "password";
SecureString securePassword = new SecureString();
for (int i = 0; i < password.Length; i++)
securePassword.AppendChar(Convert.ToChar(password[i]));
info.UserName = "userName";
info.Password = securePassword;
info.Domain = "domain";
try
{
Process.Start(info);
}
catch (System.ComponentModel.Win32Exception ex)
{
Console.WriteLine(ex.Message);
}
}
上面的代码抛出错误The system cannot find the file specified。在不指定用户凭据的情况下运行相同的代码可以正常工作。我不确定它为什么会抛出这个错误。
谁能解释一下?
【问题讨论】: