Opening EXE Files Directly in Firefox

WARNING: This has been considered a very bad idea by some. Only continue if you are absolutely certain you are capable of using this safely!

The Problem

Mozilla Firefox is a great browser! It is open-source, extensible and much more security-aware than Internet Explorer. However, due to its security, some of its features are crippled compared to IE equivalents. In particular, Firefox does not allow or provide any configurable option for directly opening executable (EXE) files from the web the same way IE permitted.

The Solution

I followed the instructions outlined in two comments on OSDir.com (this one and this one) and found it worked great on Firefox 1.5.0.1 (the latest version as of 17/02/2006). It was the second article that provided the exact modifications to be made on the 1.0 series of the files, while the first one presumably shows the proper files for the 0.7 series (I haven't tried this).

In short, here's what you do:

  1. The very first thing to do is close Firefox. Open this page in Internet Explorer or copy & paste it in some text editor.
  2. Find the directory where Firefox is installed (e.g. C:\Program Files\Mozilla Firefox). Browse to the components directory.
  3. Open the nsHelperAppDlg.js file with a Unix line ending-compatible editor (for example, Microsoft WordPad).
  4. For version 1.5.0.1 (file size 36,761 bytes), find the following lines and comment them by inserting a double-slash (//) at the beginning of each one:

    360       var mimeType = this.mLauncher.MIMEInfo.MIMEType;
    361       if (mimeType == "application/octet-stream" || 
    362           mimeType == "application/x-msdownload" ||
    363           this.mLauncher.targetFile.isExecutable()) {
    364         rememberChoice.checked = false;
    365         rememberChoice.disabled = true;
    366       }
    367       else {

    (leave line 368 as it is)

    369       }

    (skip ahead about 170 lines)

    538       if (this.mLauncher.targetFile.isExecutable() || (
    539           (mimeType == "application/octet-stream" ||
    540            mimeType == "application/x-msdownload") && 
    541            !openWithDefaultOK)) {
    542         this.dialogElement("open").disabled = true;
    543         var openHandler = this.dialogElement("openHandler");
    544         openHandler.disabled = true;
    545         openHandler.selectedItem = null;
    546         modeGroup.selectedItem = this.dialogElement("save");
    547         return;
    548       }

    Alternatively, you can download a patch file which does it all for you, assuming you have the exact same version of the file I did when I created the patch:

    nsHelperAppDlg.js-1.5.0.1-openexe.patch

  5. Open up Firefox and browse to an EXE file. The normal download box should open, only now you have the option to "Open with".
  6. Select it, and choose "Other...". Then browse and select C:\Windows\Explorer.exe.
  7. Once back in the download box, put a tick next to "Do this automatically for files like this from now on." Firefox will then launch Explorer which prompts you to "Run" or "Save" the file.

Improvements (01/06/2006)

In reality, it seems like this technique doesn't work so well all the time. George Tsai has written in, offering the following improvement. Use at your own risk, I have not tested this. He says:

It helped me immensely, but it doesnt completely work in Firefox 1.5.0.3. I think i may have found the script that handles the new protection feature. In the nsHelperAppDlg.js, i commented out line 761, and everything works as you described. Apparently, the programmers decided to keep options for.exe files from being saved into the download actions menu.

Contact

The author of this article is Catalin Patulea. Feel free to e-mail me with questions and comments. If you would like to see some of the other things I've done, check out my web site.


001563 since 17/02/2006     Valid XHTML 1.0 Strict