16

The symptoms

  • Users open their web mail accounts, click on some attachment, and click "Open with Word".
  • Users edit their precious documents for hours. Users save word doc and exit.
  • Users can't find file.
  • Users grab torches and pitchforks (last step optional).

enter image description here

The cause of the problem

The download dialog for Firefox shows two options: "Save file" and "Open with".

enter image description here

By choosing "open with", Firefox downloads the file to a temp folder and opens the associated application. I want to prevent this behavior.

What I tried

I made my homework and searched the MozillaZine, and the Knowledge Base (like here, here or here) and if I understood correctly, the download dialog box will depend not on the file's extension, but rather on its mime type.

I know I can set the behavior by going to Preferences > Applications, like this:

enter image description here

However:

  • Firefox relies on the mime type informed by the server. But it can be itself incorrect, omitted, or redundant (one file type can have multiple mime types, or vice-versa).
  • Firefox remembers the "Do this automatically for files like this from now on" check-box on a per-mimetype basis. If I want to enforce a certain behavior, I have to manually set it for each mime type.
  • I can not create new entries in the applications list. It is populated only when a new download is made from an unregistered mime type. Only then I can change the behavior in the list.
  • I can edit the mimetypes.rdf file, forcing the "save file" behavior, but I couldn't find a way to enforce this to all files.

What I need is a way to (preferably) make it impossible to open with an external application, or at least to force the file to be saved.

I know I can set browser.altClickSave in about:config to have it save the file when I click pressing ALT, but I need some solution that does not require user interaction.

6
  • Just automate these operations... Try this: addons.mozilla.org/en-US/firefox/addon/imacros-for-firefox/…
    – climenole
    Dec 5, 2014 at 3:11
  • Automate what operations? It's just a click to download. My question was long because I wanted to provide enough info. Besides, if users can't be bothered (or can't understand what happens) to click download instead of open with, then certainly a more complex solution won't work. I need something that does not require user interaction Dec 5, 2014 at 9:50
  • So you need a computer with no computer user... OK. :)
    – climenole
    Dec 5, 2014 at 13:14
  • 1
    You can just modify the incoming MIME type with one of several extensions. Set it to a MIME type that is always downloaded. Sorry, not enough time right now for a full answer, but you are smart enough to get the idea. Dec 12, 2014 at 5:53
  • 1
    I am trying to download all (even unknown mimetype) files without prompt, it seems impossible with Firefox! I need behavior like Alt-Click to be default...
    – Rast
    Jan 10, 2016 at 7:01

4 Answers 4

5

Making a master mimeTypes.rdf file that you deploy to users is the best solution

Open mimeTypes.rdf in an editor that handles XML style docs well (such as Notepad++)

Find and replace first line with second:

NC:saveToDisk="false"
NC:saveToDisk="true"
  and
NC:alwaysAsk="true"
NC:alwaysAsk="false"  

I would also "seed" your master mimeTypes.rdf with some of the exotics your users have accumulated:

  1. Copy mimeTypes.rdf from the 2-3 users with the heaviest usage of webmail attachments
  2. Compare users' types to your master:

cmd.exe

find "<RDF:li RDF:resource=" Master_mimeTypes.rdf > MasterMimes.txt   #generate list of mimetypes
find "<RDF:li RDF:resource=" User1_mimeTypes.rdf > User1Mimes.txt     #generate list of mimetypes
fc MasterMimes.txt User1Mimes.txt                                     #compare lists of mimetypes

If you find any new types, grab the whole stanza from the user's file and add to master.

1
  • 3
    Unfortunately, that is not practical at all. I have no idea what types I will download in the future. Also, some file-types (like exes) don't work at all.
    – Synetech
    Nov 4, 2017 at 17:44
3

In about:config there is now an option browser.download.forbid_open_with. Just set it to true

0

NOTE: The instructions are Windows specific, but will work for other OSes. This solution will not work for PDFs without disabling PDF.js and/or other PDF viewer plugins. It also won't work for files which Firefox can open directly (e.g. MP3 files, images, videos, text/plain files, etc.)


Well, this solution isn't as user interaction free as you'd want, but if you have the ability to provide customized versions of Firefox or you can run batch scripts on each user's computer, you can try this:

  1. Install the latest beta version of Automatic Save Folder (ASF)

  2. Create a filter to match any kind of file from any domain like this.
    Also make sure you read the 1st Install Guide ASF Filter

  3. Configure ASF to automatically choose Save File from the Save dialog Choose auto save

  4. Install FEBE and backup the browser profile (including preferences) and restore them on individual computers

Or, if you can run batch scripts on the user's computer, run the following script (after ASF is installed):

Filename: Configure ASF.bat
@ECHO OFF
:: Kill Firefox if it is running or else prefs.js won't be updated
START "" /WAIT /B "taskkill" /F /IM firefox.exe

:: Find out the user profile directory for Firefox and navigate to it
SET ProfileDir=%APPDATA%\Mozilla\Firefox\Profiles
CD /D %ProfileDir%
FOR /F "tokens=* USEBACKQ" %%F IN (`dir /A:D /B ^| find "default"`) DO (
SET "ProfileDir=%ProfileDir%\%%F"
)
CD /D %ProfileDir%

:: Read  ASF preferences from 'extpref.txt' and append them to Firefox's preferences file
TYPE %~dp0%\extpref.txt >> prefs.js

:: Since the username for each user is bound to change, find out the path to the "Downloads"
:: folder and append it to prefs.js
SET DownloadsDir=%USERPROFILE%\Downloads
ECHO user_pref("extensions.asf.filters0.folder", "%DownloadsDir:\=\\%"); >> prefs.js
ECHO user_pref("extensions.asf.lastpath", "%DownloadsDir:\=\\%"); >> prefs.js

PAUSE
Filename: extpref.txt
user_pref("extensions.asf.dialogForceRadio", true);
user_pref("extensions.asf.dialogaccept", true);
user_pref("extensions.asf.filters0.active", true);
user_pref("extensions.asf.filters0.domain", "*");
user_pref("extensions.asf.filters0.domain_regexp", false);
user_pref("extensions.asf.filters0.filename", "*");
user_pref("extensions.asf.filters0.filename_regexp", false);
user_pref("extensions.asf.filtersNumber", 1);
user_pref("extensions.asf.tempdomain", "http://chrisblattman.com");
user_pref("extensions.asf.useDownloadDir", true);
user_pref("extensions.asf.version", "1.0.5bRev128");
user_pref("extensions.asf.viewdloption", true);
user_pref("extensions.asf.viewpathselect", true);
user_pref("[email protected]", true);

The script takes input from extpref.txt which should be present in the same folder as the script itself and must contain preferences for ASF, which will be updated in Firefox's preferences file (prefs.js)

You can read the preferences from about:config under extensions.asf.* or simply get them from prefs.js which will typically be in the folder:

%APPDATA%\Mozilla\Firefox\Profiles\????????.default\

When creating extpref.txt make sure you don't include extensions.asf.filters0.folder and extensions.asf.lastpath since they will be different for each user.

0

For the more recent versions of Firefox you want to edit the handlers.json file and add a new mimetype. If you look at the default mimetypes that are already there you can add them and actions pretty easily. Just remember that "0" is for downloading in the actions. Be sure to make a backup just in case you screw something up.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .