How to prevent Wine from adding file associations?

Wine automatically adds certain mimetypes and file associations (e.g. notepad.exe for .ini files). There already is an answer that explains how to remove these associations.

But how can one prevent Wine from adding them again and again?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Disabling winemenubuilder.exe altogether will prevent wine from hijacking your file associations, but it will also prevent it from creating menu entries for newly installed software, which may be an undesired behavior. The better solution is this:

  1. Remove existing wine hijacks (from wine FAQ):

    rm -f ~/.local/share/mime/packages/x-wine*
    rm -f ~/.local/share/applications/wine-extension*
    rm -f ~/.local/share/icons/hicolor/*/*/application-x-wine-extension*
    rm -f ~/.local/share/mime/application/x-wine-extension* 
    
  2. Edit /usr/share/wine/wine.inf (as root), find the [Services] section:

    [Services]
    HKLM,%CurrentVersion%\RunServices,"winemenubuilder",2,"%11%\winemenubuilder.exe -a -r"
    ...
    

    and edit it so it says:

    [Services]
    HKLM,%CurrentVersion%\RunServices,"winemenubuilder",2,"%11%\winemenubuilder.exe -r"
    ...
    

    (namely, to start winemenubuilder.exe without the -a switch).
    This will prevent updating file associations on new user accounts (or with new WINEPREFIXes).

  3. Edit your $WINEPREFIX/system.reg file (if it exists) in similar fashion. Where it says

    [Software\\Microsoft\\Windows\\CurrentVersion\\RunServices]
    "winemenubuilder"="C:\\windows\\system32\\winemenubuilder.exe -a -r"
    

    remove the -a switch. (By default, WINEPREFIX=$HOME/.wine.)

This will prevent wine from stealing your preferred mimeapps, but the winemenubuilder will still run and create convenient desktop entries for your Windoze software.

Solution 2

From http://wiki.winehq.org/FAQ:

Users who do not want the installer for a Windows app to change filetype associations, add menu items, or create desktop links, can disable winemenubuilder.exe . There are several ways to do this:

  • In winecfg: before running the installer, run winecfg. Go to the Libraries tab and type winemenubuilder.exe into the “New overrides” box (it is not in the dropdown list). Click add, then select it from the “Existing overrides” box. Click “Edit” and select “Disable” from the list, then click “Apply”.

  • Registry file: If you need to apply the setting many times (e.g. every time you recreate the Wine prefix), this approach may be more convenient. Create a text file named with extension .reg (e.g., disable-winemenubuilder.reg) containing the following:

    [HKEY_CURRENT_USER\Software\Wine\DllOverrides] 
    "winemenubuilder.exe"=""
    

    To apply the setting, run regedit disable-winemenubuilder.reg

  • Environment variable: set the WINEDLLOVERRIDES environment variable when you run the installer, e.g.,

    WINEDLLOVERRIDES=winemenubuilder.exe=d wine setup.exe
    

Disabling winemenubuilder.exe will cause wine programs to print errors that they cannot find it (though the errors do not seem to interfere with program operation).


An alternative approach that avoids the errors is to replace it with the do-nothing program. Compile the following with MinGW’s gcc under wine and place the executable at C:\Windows\System32\winemenubuilder.exe:

  int main() { /* Do nothing */ return 0; }

Then follow the same procedure as above, but set winemenubuilder.exe to “native” instead of “disable”.

Solution 3

Since this is the first hit on Google. The Wine FAQ now lists an alternative method for newer versions of wine.

“Beginning with wine-3.14, winecfg has a “Manage File Associations” checkbox on the Desktop Integration tab. Checking it enables winemenbuilder to create file associations and unchecking it disables that behavior.”

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply