C# how to change default browser?

BotBuilding

New member
Aug 15, 2014
5
0
0
Hello guys,

I'm using iMacros API to navigate browser to specific website.It's using ie7 as a default browser,how can i change it to ie9 or ie10? any other version.I added my application in regedit using Dword with vshost but still it's navigating web using ie7.Can anyone help me with it?

Thanks
 


Well, now you have a reason to drop the browser completely. At least learn to use Fiddler and WebRequests, otherwise you can't make anything serious anyway.
 
No,ie7 is not my default browser,it's only in iMacros and when i'm adding browser control to C# application it's also navigation web using ie7
 
Uninstall IE7 and IE9 and install IE 10 then? I didn't even know you could have multiple IEs installed at the same time.
 
You might consider using selenium if you want a browser you an easily automate from c#.
 
I highly recommend Awesomium Awesomium - HTML UI Engine for C# projects. I've been using it for quite some time now and it works pretty well. You can either use their web control or you can run it headlessly if you don't want the overhead of rendering, which is a plus and the way I run it most of the time.

The default web browser control in .net is just a wrapper around IE ActiveX and isn't anything I'd recommend for a scraper/bot type thing. You're basically carrying over all the BS with IE which is based on the IE you have installed, so if you have IE7 installed, that's what you're going to get with it.

Awesomium makes it easy to execute/evaluate JS so you can take advantage of jquery if the site you are automating has it or even inject it yourself if that's what you need. It's definitely a LOT easier to work with than the stock browser control for pretty much any use case.

Anyway, it's definitely something to consider. If I have my choice of tools, I normally go for Ruby with poltergeist (PhantomJs wrapper) and celluloid and I'll use redis and rarely rabbitmq for a queue and allowing processes to easily communicate. I still have clients that I'm supporting c# apps for and that's when I turn to Awesomium. Hope this helps.
 
You can modify registry

Change registry key for the
HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell \ Associations\UrlAssociations\http
Say you want to change your default browser to IE using c#

You can use following code


RegistryKey regkey =Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\shell\\Associations \\UrlAssociations\\http\\UserChoice",true);
string browser = regkey.GetValue("Progid").ToString();
if(browser !="IE.HTTP")
{
regkey.SetValue("Progid","IE.HTTP");
}