MS Bob 11 Posted October 4, 2009 Share Posted October 4, 2009 Suppose if I set different or even multiple home pages for Firefox, IE, Chrome, Opera and Safari. Now if I set any one of those as the default browser, is there a way to open the default browser from the command line/run/script/batch file/powershell? There's one key here: HKEY_CLASSES_ROOT\http\shell\open\command but that appends "-nohome" to IE if I return that value in a script. Link to comment https://www.neowin.net/forum/topic/830086-any-way-to-launch-the-default-browser-from-the-command-line/ Share on other sites More sharing options...
Nedlinin Posted October 4, 2009 Share Posted October 4, 2009 This is sort of cheating.. but, if you open up your Start Menu and drag the "Internet" shortcut from the top of the list out to the desktop, you then have an "Internet - Shortcut.lnk" file on your desktop. Just have your program call upon this shortcut. This shortcut will update itself if the default browser on the system changes. Link to comment https://www.neowin.net/forum/topic/830086-any-way-to-launch-the-default-browser-from-the-command-line/#findComment-591661506 Share on other sites More sharing options...
BajiRav Posted October 5, 2009 Share Posted October 5, 2009 Enter this on command line : start <some address> such as start www.neowin.net Link to comment https://www.neowin.net/forum/topic/830086-any-way-to-launch-the-default-browser-from-the-command-line/#findComment-591662478 Share on other sites More sharing options...
MS Bob 11 Posted October 5, 2009 Author Share Posted October 5, 2009 That shortcut is only there up to Vista. I'm on Windows 7. And start <URL> launches that specific URL. If I've set different homepages for each browser, it's not of use to me. Link to comment https://www.neowin.net/forum/topic/830086-any-way-to-launch-the-default-browser-from-the-command-line/#findComment-591662660 Share on other sites More sharing options...
gdodson Posted October 5, 2009 Share Posted October 5, 2009 I haven't tested it on 7 yet, but in Vista the default browser is stored here: [HKEY_CURRENT_USER\Software\Clients\StartMenuInternet]. Just read in the Default string and then you should be able to just start that browser. Link to comment https://www.neowin.net/forum/topic/830086-any-way-to-launch-the-default-browser-from-the-command-line/#findComment-591662710 Share on other sites More sharing options...
soumyasch Posted October 5, 2009 Share Posted October 5, 2009 In Powershell $registrykey = [Microsoft.Win32.Registry.ClassesRoot]::OpenSubKey("htmlfile\shell\open\command", $false) [string] $browserpath = $registrykey.GetValue("", "").Split('"')[1] [System.Diagnostics.Process]::Start($browserpath) Just save it as a function and call it. You could also use the command in "http\shell\open\command". Just replace "htmlfile\..." with "http\..." and run. Link to comment https://www.neowin.net/forum/topic/830086-any-way-to-launch-the-default-browser-from-the-command-line/#findComment-591662764 Share on other sites More sharing options...
jnelsoninjax Posted October 6, 2009 Share Posted October 6, 2009 dhan said: Enter this on command line : start <some address> such as start www.neowin.net this works only if you place http:// in front of the address, otherwise windows says it can not locate the file! Link to comment https://www.neowin.net/forum/topic/830086-any-way-to-launch-the-default-browser-from-the-command-line/#findComment-591667234 Share on other sites More sharing options...
MS Bob 11 Posted October 6, 2009 Author Share Posted October 6, 2009 None works. There are some classic VB examples here, some VB.NET examples here and some C# examples here but I'm not a dev. I don't want to launch a specific URL. I want to launch the default browser's set homepage whatever that may be. Link to comment https://www.neowin.net/forum/topic/830086-any-way-to-launch-the-default-browser-from-the-command-line/#findComment-591667656 Share on other sites More sharing options...
Wilhelmus Posted October 6, 2009 Share Posted October 6, 2009 Try this batch script: @echo off for /f "tokens=2*" %%A in ('reg query HKCU\Software\Clients\StartMenuInternet /ve') do ( start %%B ) Link to comment https://www.neowin.net/forum/topic/830086-any-way-to-launch-the-default-browser-from-the-command-line/#findComment-591667836 Share on other sites More sharing options...
MS Bob 11 Posted October 6, 2009 Author Share Posted October 6, 2009 The HKCU\Software\Clients\StartMenuInternet key is deprecated in Windows 7. While it exists, it may not be set by browsers in the future. Plus Chrome doesn't work as it puts a value of "Google Chrome" there instead of Chrome.exe. Also Opera doesn't work as Opera's app path isn't registered by default. Link to comment https://www.neowin.net/forum/topic/830086-any-way-to-launch-the-default-browser-from-the-command-line/#findComment-591668054 Share on other sites More sharing options...
Recommended Posts