This is obviously going to vary by browser, but its clear you've done almost no research on this so I'll be your research assistance.
Note
Generally you can just execute the URL on the path, and the default browser will open a new tab or start as nessesary. there shouldn't be any need to do the following. execute explorer.exe "http://google.com"
in your CMD window to see how this works with various default browsers.
Answer
I googled "How to detect the default browser C#"
which yielded several results, the first of which is How to find default web browser using C#? - this has a couple answers, the second one seems to be the one that you want.
Once you know the default browser, you need to check if it's open. So you will need to compile a list of binary names for each browser (chrome is chrome.exe
) and we search for "check if process is running C#"
and that gives us How can I know if a process is running?
Now, we know if the browser is running. If it is we will have a Process
instance - so we need to now know the binary location (this is important!). So we search for Get the path of a running process C#
and that gives us C#: How to get the full path of running process?
Each browser will have it's own mechanism for opening a new tab and receiving focus, but generally you need to execute the binary with some arguments. For Google Chrome, the answer is here: https://superuser.com/questions/731467/command-line-option-to-open-chrome-in-new-window-and-move-focus
So now we have completed everything for the google chrome browser. Repeat for other browsers, and do similar research to find out how to execute the binary to open a new tab.
If you want a generic solution that works for all browsers, this already exists. just execute explorer "yourUrl"
.