[tags]firefox,file link,share,local link[/tags]
Update 04-12-2007: please see my latest blog entry on handling of file links in Firefox (and other protocols) here.
In Internet Explorer you can link to a file or folder on your own harddrive (local pages) or network share using anchor html code like … href=”\serversharefolder” …
Due to security restrictions in Firefox and (as far as I know) all other browsers except IE, such a link will not work.
The best solution I found was to add a handler for smb links in the Windows registry, which invokes a small program that opens the correct link in Windows Explorer.
The fix consist of two files:
- smb.reg contains registry settings so that the system, including all browsers ie. Firefox, IE and others, recognize smb links such as smb://\serversharefolder
- smb.cs is the source code for smb.exe. When called it will start Windows Explorer on the requested file. When you click a link in your browser the href will be url encoded. The code handles links containing url-encoded characters such as the danish æ,ø and å. Failure to decode such characters will prevent Windows Explorer in finding the requested folder.
Windows Registry Editor Version 5.00
/// Takes a smb:// link and starts Windows Explorer in the folder
/// which the link points to.
public class smb
public static void Main(string args)
if (args.Length == 0)
Console.Write(“No destination given”);
string dest = args.Replace(“smb://”,string.Empty);
if (dest.EndsWith(“/”)) // explorer prefer if paths to folders end with or nothing
dest = dest.Substring(0, dest.Length – 1);
// allow smb://server/share style links
dest = dest.Replace(‘/’, ‘\’);
// rescue some non-conformant URL’s
dest = “\\” + dest;
// since the link probably came from a browser we need to restore
// non-english characters such as æ,ø and å from their html-encoded version
dest = System.Web.HttpUtility.UrlDecode(dest);
// use explorer to start folders,
// files are launched without a program. this assumes proper handlers are set up
The registry code can be put into a .reg file and imported by double-clicking it or silently using regedit /s smb.reg.
You can compile smb.cs to obtain smb.exe by putting the above code into a file called smb.cs and then invoke the csharp compiler,csc, on it (my compiler lies here %windir%Microsoft.NETFrameworkv2.0.50727).
To complete the fix you must copy smb.exe to a folder, which is in your path eg %windir%.
If you really trust me you can skip the compilation part and download both files.
Update 09-11-2007: smb.exe will now launch files by executing them directly. Folders are still launched with Windows Explorer.