Jump to content

Set Default Portable Browser in Registry (Correctly handles .URL files)


robertcollier4

Recommended Posts

I wrote this because I was unable to find any working tools on the Internet to correctly change the default browser association in Windows (such as if you want to use a portable edition of a browser).


The problem with all of the other tools on the Internet is that they do not correctly handle .URL files. Since .URL files are text files - they have to be passed to "HKEY_CLASSES_ROOT\InternetShortcut" where the URL gets parsed by shdocvw.dll and then passed to HKEY_CLASSES_ROOT\http. With other tools - the .URL files would open as text files in the browser instead of opening the actual URL itself. This script does it correctly.

 

 

defaultbrowserinregistr.gif

 

Download here:

http://www.autohotkey.com/board/topic/89803-set-default-browser-in-registry-correctly-handles-url-files/

 

Silent mode: If no command line arguments will show GUI. Will run in silent mode if argument passed to it on command line. Silent mode if successful does not write anything to command line / stdout (Autohotkey does not natively support writing to stdio)- if you are running in silent mode and the utility runs without any popups or warning dialogs - then the change was successful.
Silent mode example: DefaultBrowserInRegistry.exe "D:\PortableApps\GoogleChromePortable\GoogleChromePortable.exe"
Edited by robertcollier4
Link to comment
Share on other sites

Can it be run in command line (silently) ?

Good idea. I have updated the script to accept a command line argument to run in silent mode. When run with an argument on the command line, the only time it will popup a dialog is to display an error message if it has received a path which it is unable to parse. (AutoHotkey does not natively support writing to stdio / stderr). If you pass it a correctly formed path - it will run completely silently and produce no dialogs.

Edited by robertcollier4
Link to comment
Share on other sites

Hi robertcollier4,

 

Tested with Firefox 18.0.2 and Win7 X64.

 

 

tested in command line and GUI

 

 

 DefaultBrowserInRegistry.exe "C:\Program Files (x86)\Mozilla Firefox\Firefox.exe" 

 

 

Doesn't work.

 

How do you know it didn't work? What is the problem you are having? When running in silent mode - if it worked - there is no output / nothing written to command line.

 

What is the content of the following key in regedit.exe? - HKEY_CLASSES_ROOT\MyHTMLFile\Shell\Open\Command

Link to comment
Share on other sites

How do you know it didn't work? What is the problem you are having?

 

 

because IE was still the default program (you can check that easily in control panel) and besides Firefox still asking to be the default browser when launched.

Link to comment
Share on other sites

because IE was still the default program (you can check that easily in control panel) and besides Firefox still asking to be the default browser when launched.

Firefox asking to be the default browser when launched will still happen when using this tool - because Firefox writes its own custom Handler type for example class "FirefoxHTML" whereas I use a generic class "MyHTMLFile" in this script. Regardless, it says nothing as per the functionality of whether this works. This tool was designed mainly for Portable versions of browsers in which checking for default browser should be disabled anyways - and this tool does not guarantee to mimic exactly the classes used by all the different browsers - but its goal is just to write all the keys so that they are correctly functional.

 

The most important thing to see is if direct launching http links, launching htm/html/mht files, and launching url files is working or not. When you click on a htm file from the explorer - is it opening with the browser you specified? All of the other things are cosmetic only.

 

Regarding the browser displayed in Control Panel for Windows 7, is this the screen you are looking at, and would you mind doing a check for me since I do not use Windows 7? Could you open up regedit and make the following change?

HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice

"ProgId"="MyHTMLFile"

 

Try redownloading the file - I have added UserChoice reg entries to the tool and tell me if this changes what Windows 7 shows in Control Panel.

Edited by robertcollier4
Link to comment
Share on other sites

  • 8 months later...

 

I wrote this because I was unable to find any working tools on the Internet to correctly change the default browser association in Windows (such as if you want to use a portable edition of a browser).

The problem with all of the other tools on the Internet is that they do not correctly handle .URL files. Since .URL files are text files - they have to be passed to "HKEY_CLASSES_ROOT\InternetShortcut" where the URL gets parsed by shdocvw.dll and then passed to HKEY_CLASSES_ROOT\http. With other tools - the .URL files would open as text files in the browser instead of opening the actual URL itself. This script does it correctly.

 

 

defaultbrowserinregistr.gif

 

Download here:

http://www.autohotkey.com/board/topic/89803-set-default-browser-in-registry-correctly-handles-url-files/

 

Silent mode: If no command line arguments will show GUI. Will run in silent mode if argument passed to it on command line. Silent mode if successful does not write anything to command line / stdout (Autohotkey does not natively support writing to stdio)- if you are running in silent mode and the utility runs without any popups or warning dialogs - then the change was successful.
Silent mode example: DefaultBrowserInRegistry.exe "D:\PortableApps\GoogleChromePortable\GoogleChromePortable.exe"

 

This Great!!

 

 

but a small question:
when I open a .chm file is not displayed correctly.
Their submenus are opened in the default browser before established not in the main window.
You observed this strange behavior as due to the script?
Link to comment
Share on other sites

  • 3 months later...
  • 9 months later...

Hi,


 


Thanks for that, It is working just fine for all browsers. 


I have no experience in scripts but I wanted to know if it was possible to edit the script to make chrome (for example) the default browser in one click only without the need to enter the path manually in the GUI


 


Thanks :)


Link to comment
Share on other sites

I don't think that request makes sense because the script is meant for portable browsers which do not have a defined location where they are located.  You have to tell the script somehow specifically where the browser is located.

 

Cheers and Regards

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 years later...

For those that have found this thread from search and are having problems in Win7 and above, I made a new less invasive reg script for this for Win7 attached. This is as a reg file instead since its easier to read. Youll need to do a find-replace as instructed in the file on your Browser path.

Changes:
This one is less invasive and doesnt replace the HKEY_CLASSES_ROOT keys, but rather uses the new Win7 UserChoice entry method so that you can use Control Panel > Default Programs > Set your default programs > Choose defaults for this program to make them active at:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.xxx\UserChoice

StartMenuInternet FileAssociations Win7.reg

Edited by robertcollier4
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...