我使用下面的code到火IEXPLORE进程。这是一个简单的控制台应用程序完成的。
I am using the following code to fire the iexplore process. This is done in a simple console app.
public static void StartIExplorer()
{
ProcessStartInfo 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);
}
}
以上code抛出错误{系统找不到指定文件}。不指定用户凭据运行时,同样的code正常工作。我不知道为什么它是引发此错误。
The above code is throwing the error {"The system cannot find the file specified"}. The same code when run without specifying the user credentials works fine. I am not sure why it is throwing this error.
有人能解释一下吗?
感谢。
尝试替换您的初始code:
Try to replace your initialization code with:
ProcessStartInfo info = new ProcessStartInfo(@"C:Program FilesInternet Exploreriexplore.exe");
使用上的Process.Start非完整文件路径只有当文件在System32文件夹中找到工作。
Using non full filepath on Process.Start only works if the file is found in System32 folder.
上一篇:MSTest的:CollectionAssert.AreEquivalent失败。预期集合包含1发生(S)发生、MSTest、CollectionAssert、AreEquivalent
下一篇:.NET:是否有InvariantCulture的之间和en-US什么区别吗?什么区别、InvariantCulture、NET、US