G
garyusenet
I have been trying for some time now to launch Internet Explorer from
my code. I have read the MSDN notes on this way of starting processes
and used their example but couldn't get it to work.
I then searched the forums and made ammendments suggested to previous
posters but it still isn't working. Here is my StartInternetExplorer()
method. Could you please look and see what I am doing wrong?
Thankyou.
Gary.
private void StartInternetExplorer()
{
Process myProcess = new Process();
try
{
myProcess.StartInfo.FileName = "c:\\Program
Files\\iexplore.exe";
myProcess.StartInfo.Arguments =
"http://www.google.co.uk";
myProcess.EnableRaisingEvents = false;
myProcess.Start();
myProcess.WaitForExit();
}
catch (Win32Exception e)
{
if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
{
Console.WriteLine(e.Message + ". Internet Explorer
not in default location.");
}
else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
{
// Note that if your word processor might generate
exceptions
// such as this, which are handled first.
Console.WriteLine(e.Message + ". You do not have
permission to run this file.");
}
}
}
my code. I have read the MSDN notes on this way of starting processes
and used their example but couldn't get it to work.
I then searched the forums and made ammendments suggested to previous
posters but it still isn't working. Here is my StartInternetExplorer()
method. Could you please look and see what I am doing wrong?
Thankyou.
Gary.
private void StartInternetExplorer()
{
Process myProcess = new Process();
try
{
myProcess.StartInfo.FileName = "c:\\Program
Files\\iexplore.exe";
myProcess.StartInfo.Arguments =
"http://www.google.co.uk";
myProcess.EnableRaisingEvents = false;
myProcess.Start();
myProcess.WaitForExit();
}
catch (Win32Exception e)
{
if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
{
Console.WriteLine(e.Message + ". Internet Explorer
not in default location.");
}
else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
{
// Note that if your word processor might generate
exceptions
// such as this, which are handled first.
Console.WriteLine(e.Message + ". You do not have
permission to run this file.");
}
}
}