How to prevent Wine from adding file associations?

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.


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".


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."

Tags:

Wine

Mime Type