Click here to Skip to main content
15,947,389 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Here is what I have a W7 64 bit Pro Visual Studio 2019
I have Google and Firefox installed as the default Browser
DuckDuckGo default Search Engine
I have a VB.Net app that stores the web address in a SQLite DB
Click on the link in a Data Grid View & it opens the YouTube site
with this cmd
Process.Start(webPAGE)

Some are formatted this way
"https://www.youtube.com/@KRWoodworks/videos"
Others this way
"https://www.youtube.com/user/DrunkenWoodworker/videos"

What I would like to do is add code to the Best Links VB.Net
app that lets me set the default Browser and when the Best Links
app closes sets it back to Firefox
OR a stand alone app in VB.Net or C# that lets me set the default browser
OR a BATCH file that lets me set the default Browser
this would require knowledge of how to write a BATCH File
I understand the basics of this but have NO Experience
and do not like to mess with the Registry
When I say Default Browser it has to be Google Chrome because
Google is not loading YouTube video's because it finds Firefox
If a BATCH file is the only option can I run a BATCH file from
a VB.Net app ?

What I have tried:

I have looked at a number of post's about this concept
One said Process.Start(webPAGE) is a bad idea ?
When I wrote the Best Links app I grabbed the first line of code that worked
I looked at this not exactly what I want
Chocolatey Software | SetDefaultBrowser 1.5.0[^]
This looks GOOD but I do not understand all the code and we
are talking a 12 yr old post sure my OS is that Old ha ha
https://superuser.com/questions/368814/how-do-i-change-my-default-browser-to-an-unlisted-program-in-windows-7[^]
IMPROVED question
OK I am able to open the Browser with this code
Process.Start(webPAGE)
Dim browser As String
browser = "http://www.google.com/"
Process.Start(browser)

This creates a issue that the Browser gets opened every time
I load a new video from a YouTube channel
So I need a if statement that determines if the Browser is open
I am working on that
Posted
Updated 20-Jun-24 15:58pm
v2

Why want you change default browser?

You can start Chrome with process

Process.Start("pathToChrome\\chrome.exe", "webPAGE")
https://stackoverflow.com/questions/10849638/how-to-open-a-website-with-google-chrome[^]
 
Share this answer
 
Comments
Choroid 20-Jun-24 22:02pm    
I need to use Google Chrome to view YouTube video's
If I use my default Browser Firefox YouTube will not play the video
Thanks for the code link I used that link to open a browser
see my improved statement under what I have tried
Richard Deeming 21-Jun-24 3:36am    
This is an example of an XY problem[^]. Rather than asking for help with the real issue ("how do I open a URL in a specific browser?"), you have decided that you MUST need to change the default browser somehow, and are now asking for help to do that.

And despite having two people tell you that you just need to open the site in a specific browser, and giving you code to do that, you're still trying to solve the problem you created with your chosen solution to the real problem.
HỒNG TRẦN THỊ 22-Jun-24 11:40am    
Yep
Choroid 21-Jun-24 11:37am    
Richard I agree I should have explained that Google will not load YouTube videos unless you have Google Chrome open sadly I thought I needed to be logged in to Google to make the YouTube video play. I had already used Jo_vb.net code link when he posted his Solution See Response to OG's Solution Thanks for the insight
Never change default apps: it's the simplest way to get your app uninstalled.

Think about it: MS forces you to use Edge sometimes and that means you avoid some features of their apps - if you start playing with system wide settings because you prefer it for whatever reason then you will annoy users and they will demand their money back.

If you must use a particular app for a certain action then specify that as part of the Process.Start - specify an application, and pass it the URL as an argument instead of trying to change system settings: Process.Start Method (System.Diagnostics) | Microsoft Learn[^]
 
Share this answer
 
Comments
Choroid 21-Jun-24 11:30am    
Paul "OG" first thanks for the answer. The app is for my use only but that said I do agree with what you point out changing system wide settings without explaining to the EU not good UI design. I almost had the problem solved with this code you will see the mistake I kept thinking I need to log in to Google.
'Dim browser As String
'browser = "http://www.google.com/"
'Process.Start(browser)
'Process.Start(webPAGE)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900