How to open a url in new tab of IE8 using c# (window application) for window 7

Posted on 2009-12-31
Last Modified: 2012-05-08
I have created a toolbar for IE8. There is add button in the toolbar and onclick of that i want to open a url in the new tab.

I have used the following code which is working fine for window XP browser

System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo("IEXPLORE.EXE");
 startInfo.UseShellExecute = true;
 startInfo.FileName = url;

But for window 7 it opened the url in the new window but i want it to be opened in the new tab of same browser.

Is there any other way to do this for window 7 browser.

Waiting for ur response.

Question by:jasbirbrar
    LVL 39

    Expert Comment

    by:Kyle Abrahams

    This guy was trying to do something else but the code should open up a new tab.  There also seems to be a NewWindow2 event.
    LVL 3

    Expert Comment

    try the following code:


    private static extern int ShellExecute(int hwnd, string lpOperation,

          string lpFile, string lpParameters,

          string lpDirectory, int nShowCmd);

    public static int GoUrl(string lcUrl)

          string lcTPath = Path.GetTempPath();
          int lnResult = ShellExecute(0,"OPEN",lcUrl, "",lcTPath,1);

         return lnResult;

    Author Comment

    I already have tried these solutions but these are not working for window 7 browser. It opened the url in the new window instead of new tab of existing browser.

    Author Comment

    Actually I think the problem lies with the IE8 on Windows 7 only.
    The default behaviour of IE8 is that for new window is that it doesn't start new Session. For new Session there already exists New Session option. But in my case it is starting new session by default.
    Anything to counter that?
    LVL 39

    Accepted Solution


    Is your default setting to open a popup in a new window?  It could be a function of IE rather than your code.
    LVL 39

    Expert Comment

    by:Kyle Abrahams
    Would recommend a split between

    ROIEB, Comment Id 26162766

    Ged325, Comment ID 26189936

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now