I want to open IE from a forms application. A bit like daniweb does it btw.!
I have the following in a button click eventhandler:

Process MyProcess = new Process();
            //string MyPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

            MyProcess.StartInfo.Domain = "";
            MyProcess.StartInfo.FileName = "iexplore.exe"; //MyPath + "\\iexplore.exe";
            MyProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
            MyProcess.StartInfo.CreateNoWindow = false;
            MyProcess.Start();

This is what I want, but it just opens a IE window.
The next code goes to the website I want, but opens it in a maximised window or it opens in IE if it is already open which is not what I want.

string link = "www.google.com";
            System.Diagnostics.Process.Start(link);

I googled,daniwebbed etc. for hours, perhaps with bad search strings, but could not find an answer.
Anybody any suggestion? It must be simple in my opinion, but my mind has one of its off days I think...

Recommended Answers

All 6 Replies

Does it have to be IE? If you just run the link as a system call, it will open the default browser.

commented: The solution to a question is sometimes a question! +2

Most of the time I Safari. But when I C# I'm under Vista on a Mac. So it's IE, I don't care. My second option does almost what I want. But I want my site to always open in a separate window which is a bit smaller than the applicationwindow that opened it. At least daniweb does it, so why can I? With a little help from my fiends in this case...

I believe if you call iexpore with "-new" and then the url so it goes "iexplore -new http://blah.com" it should work.

Does it have to be IE?

Hmm...Started thinking(doesn't always happen) ... What if I let my button open a new form with a Webbrowsercontrol in it? Yes!!
Thanks LizR!! Problem solved!! This is even better because this way I can open just only one website, just like I wanted.

I now found out that a simple call like
Process.Start("IExplore.exe", "http://blah.com");
also does the trick I wanted.

I assumed you were having problem with a new window, Ie maybe set not to use a new window but reuse of course.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.