Table of Contents

Windows Start Menu

This page outlines tricks I have performed with my Start Menu which may be of interest to others.

Intergrating a new Mail Client / Internet Browser

Properly intergrated webbrowsers and mail clients appear in the top left of the start menu, with descriptive text below them (“Mozilla Firefox” and “Mozilla Thunderbird” in this case), and if you right click on them you get a completely different context menu from the usual one:

Now, I actually use Portable Firefox and Portable Thunderbird, which are designed to run from within a single folder and not rely on anything outside of it — this is in contrast to the usual installation of Firefox or Thunderbird which uses the “Local Settings” and “Application Data” directories (or “folders” in Windows-speak) to keep profile data. One copy of Firefox has a different profile for each user, which is nice when you have more than one user per PC, or you don't mind having the setting spread all over the place.

What might not be obvious until you find out the “hard way”, is that you cannot properly set these Portable versions as the default mail or internet clients. Pressing this button assigns the currently executing “firefox.exe” or “thunderbird.exe” as the default, notPortableFirefox.exe” or “PortableThunderbird.exe” which is required to setup the portable environment.

Luckily, it's not hard to alter the start menu's mail and internet clients, if you know how 8-)

First let's look at the available choices, which we shall hack in a moment. As above, right-click the taskbar and open the properties dialog shown below, and click “Customize…”:

So, the trick is to find where these entries are kept. My guess was the registry and it was not long before I found the correct entries at:

My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail
My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet

All that remains is to fiddle old Thunderbird / Firefox settings which were created by using the “Check Now” button in the options dialog to make them the default clients. I know of two ways to do this, detailed below. I pesonally use the easy way, as it seems to intergrate much more cleanly.

Easy Way

The Idea

We let (Portable) Firefox set itself as the default internet client, knowing full-well that this will setup firefox to launch without the portable profile. We then use a nifty trick to replace every execution of Firefox.exe with PortableFirefox.exe, which now launches Portable Firefox (complete with banner).

This reveals that PortableFirefox.exe launches firefox.exe, which due to our hack launches Portablefirefox.exe, which is going to launch another copy of Firefox.exe again and so on - this is bad :-(.

The solution is to bypass using PortableFirefox.exe itself, instead doing the grunt work in our own hack (this is very simple, don't worry) by having the two copies of the firefox.exe executable with different names. So we end up with firefox.exe as the default web-browser and have every execution of it replaced with (say) firefox2.exe with arguments which tell it to use your portable profile.

The Tech

!!Remember you can trivially adjust these instructions for Thunderbird instead of Firefox by replacing firefox.exe with thunderbird.exe (try THUNDE~1.EXE if that doesn't work)!!

First you want to get the “Run X instead of Y” stage done.

Launch PortableFirefox and set it as the default browser (Tools > Options > General > Default Browser > “Check Now”). Test that Start > Run > “http://www.google.com” opens in Firefox - but don't expect your profile to be loaded.

Now we'll want to do a quick test to check we can replace execution of one executable with another.

Open a registry editor and navigate to:

My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options

and make a new key called “firefox.exe”. In this new key create a “String” item, call it Debugger and set it's content to “notepad.exe” for testing purposes. Now when you use the Start Menu's Firefox icon, or Start > Run > “http://www.google.com” you ought to get notepad instead of Firefox. (NB If you're trying to get Thunderbird replaced, you might need to rename the thunderbird.exe key in the registry to THUNDE~1.EXE1))

Now you got that working, make a duplicate copy of the firefox.exe executable. Mine's called firefox2.exe.

«< | For the perfectionists ::: Copying firefox.exe just seems like a waste of hard-drive space doesn't it? It also makes auto-updating firefox.exe somewhat tricky.

You can solve both these problems by using NTFS Links — now instead of copying, make a hardlink from firefox.exe to firefox2.exe. (Do this by right-click-dragging firefox.exe and chosing “Create hard link here” when you release the right-click. Then rename the “Hardlink to firefox.exe” file to just “firefox2.exe”. Voila!

Modify the registry hack to your own version of:

"C:\PortableFirefox\firefox\firefox2.exe" -profile "C:\PortableFirefox\profile" -ignore_next_argument

:!: Note that -ignore_next_argument is not a valid command-line option for firefox, it and any non-argument following it is silently ignored because it is invalid.

Now, whenever you or another application launches firefox.exe, the above will be run instead with the complete path to firefox.exe appended to the end — for instance on my system the effective command line when I start firefox is:

"C:\PortableFirefox\firefox\firefox2.exe" -profile "C:\PortableFirefox\profile" -ignore_next_argument "C:\PORTAB~1\FIREFOX\FIREFOX.EXE" 

If you have the exact same setup as me, you can download and use the registry fragments below. I have PortableFirefox installed in C:\PortableFirefox and PortableThunderbird in C:\PortableThunderbird.

ff_image_hijack.reg tb_image_hijack.reg

(If you plan to use these fragments as a template for your own hack, please read the note on editing registry fragments at the bottom of this page on how to keep regedit happy that they're valid)

Hard Way

Change all the entries in the registry that refer to Thunderbird.exe / Firefox.exe with “PortableThunderbird.exe” and “PortableFirefox.exe”

For those who wish to use something completely different, I have uploaded the registry fragment related to Firefox and Thunderbird keys in the screenshot above, you can use this as a starting point for whatever it is you are trying to intergrate into the start menu.

start_menu_ff.reg start_menu_tb.reg

The registry fragments I use to “install” these are below. Apart from adding a new choice to the customise menu, it sets PortableFireFox / PortableThunderbird to be the chosen application as well as setting all the other associations that “Make Firefox my default browser” does, such as being associated with the HTTP/FTP/Gopher/… protocols and HTM/HTML/… pages. This was done by using Firefox's “Check Now” button in the options next to default browser and then manually searching the registry for “Firefox.exe” and changing all (relevant) occurances.2)

complete_ff.reg

Don't forget you need to select your new option from the combo list pictured earlier!

Note on Editing Registry Fragments

If you choose to open these registry fragments in a text editor (such as notepad) for strategic “Find and Replace” type activites, you might find it handy to know that Windows will likely complain that the file is not binary and will refuse to import it. You can over come this thus:

  1. Insert a space as the very first character of the file (i.e. the first line should read “ Windows Registry Editor Version 5.00”)
  2. Save this and open it in a hex editor of your choice (I used the one built into Virtual Dub's tools menu)
  3. Replace the first pair of bytes with “FF FE”
  4. Save and enjoy

Registry fragments are saved as Unicode, and this is why each character takes up two bytes, so the space you inserted made room enough for this binary signature3) Windows requires.


RobM

1)
This is a 8.3 format name, as was used in and before Win9x
2)
I left the HKEY_USER\ bits alone, as they'd be useless to anyone who doesn't have exactly the same user CLSID as me.
3)
You may be interested to know that this mark is called a Byte-Order Mark (BOM) and is a standard way to communicate the Endianess of the file. All Windows variants I am aware of are UTF16-LE