3

I need to open multiple IE tabs in C# (windows application). Below is my code:

string[] pcList = txtInput.Text.Trim().Split(',');
foreach (string pc in pcList)
{
  if (pc.Trim() != "") 
  {
    System.Diagnostics.Process.Start("http://myCom/Lookup?type=ProductCode&name=" +   pc.Trim());
  }
}

If the default browser is firefox, there is no problem.

If the default browser is IE, and one IE window was opened, there is no problem either. Multiple tabs will be opened according to the input in txtInput.

The problem I'm having is: if the default browser is IE and no IE window was opened, only one IE window and one tab will be opened. I do not know why is that and how to fix it. Can anyone help?

Thanks!

mabellez
  • 41
  • 2
  • 5

2 Answers2

0

This is what I did to get around the same problem.

            Process internetBrowserProcess = new Process();

            ProcessStartInfo psiOjbect = new ProcessStartInfo("http://DefaultWebsiteOfmyCompany.com"); // You can also use "about:blank".

            internetBrowserProcess.StartInfo = psiOjbect;
            internetBrowserProcess.Start();
            Thread.Sleep(2000); //Need to wait a little till the slow IE browser opens up.

            foreach (string websiteUrl in Properties.Settings.Default.WebSiteURLs)
            {
                Process.Start(websiteUrl );
            }
trainer
  • 369
  • 4
  • 14
0

You can call a Process.Start("url") will open browser (if it is not running) otherwise Open a new Tab(if it supports it)

Similar SO question : Open new tab in IE

Community
  • 1
  • 1
Anuraj
  • 18,859
  • 7
  • 53
  • 79