我正在使用以下代码启动 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
。当不指定用户凭据运行相同的代码时,代码可以正常工作。我不确定为什么会出现这个错误。
请有人能够解释一下吗?