45

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?

5 Answers 5

64
+150

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.

3
  • 4
    For me the path was rather /opt/wine-staging/share/wine/wine.inf. If the file is in non-standard location, run locate wine.inf to find it.
    – Hi-Angel
    Mar 30, 2016 at 4:30
  • And if you're using the stable Wine PPA, it's located at /opt/wine-stable/share/wine/wine.inf
    – wyphan
    Aug 5, 2021 at 22:43
  • Thanks. After deleting all the WINE ~/.local/share/ files, my desktop was still detecting non-existing MIME types, and preventing the correct icon to be shown. After calling update-mime-database ~/.local/share/mime/, the problem finally went away. May 9, 2022 at 14:38
19
+150

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

1
  • Okay. So for me that means I create the prefix, install my app, remove all default wine associations and menus by hand (I want the apps associations) and then change the reg key to prevent the associations from being re-added every time Wine's updated, right?
    – mniess
    Jul 27, 2013 at 16:48
13

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

2
  • 2
    This should probably be the accepted answer. That said, it doesn't work for me because I create a new WINEPREFIX for every Windows application I install.
    – hackerb9
    Jan 10, 2020 at 4:40
  • 1
    I found this thread because wine-5.0 (Ubuntu 5.0-3ubuntu1) is stealing my xdg-mime desktop file associations. This option is unchecked and I only have one wine prefix, so I don't think it's working in this version Oct 12, 2020 at 13:18
0

Here's a script that automates step 1 and 3 of Hi-Angel's answer to be used for multiple prefixes:

#!/bin/bash
# Workaround for winemenubuilder bloating file associations by default

# Remove all existing associations
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*

# Disable winemenubuilder for all existing registries
# Replace ~/.bottles with your prefix/"bottle" directories
for sysreg in $(find ~/.wine ~/.bottles -name system.reg);
do
    sed -i 's/winemenubuilder.exe -a/winemenubuilder.exe/' $sysreg
done
-1

On Gentoo to make this change permanent, you can create a user patch applied for each wine package installation automatically.

/etc/portage/patches/app-emulation/wine-vanilla/disable-winemenubuilder.patch

# disable updating file associations for mimetypes that generate much joy
# making wine-internet-explorer open images, for example.
#
# don't forget to clean up your home directory from previously generated association clutter:
#
# rm ~/.local/share/mime/packages/x-wine*
# rm ~/.local/share/applications/wine-extension*
# rm ~/.local/share/icons/hicolor/*/*/application-x-wine-extension*
# rm ~/.local/share/mime/application/x-wine-extension*
#
# then run: update-mime-database ~/.local/share/mime/

--- a/loader/wine.inf.in    2024-02-23 16:57:31.079889523 +0100
+++ b/loader/wine.inf.in    2024-02-23 16:58:26.122973075 +0100
@@ -2493,7 +2493,7 @@
 ErrorControl=1
 
 [Services]
-HKLM,%CurrentVersion%\RunServices,"winemenubuilder",2,"%11%\winemenubuilder.exe -a -r"
+HKLM,%CurrentVersion%\RunServices,"winemenubuilder",2,"%11%\winemenubuilder.exe -r"
 HKLM,"System\CurrentControlSet\Services\Eventlog\Application",,16
 HKLM,"System\CurrentControlSet\Services\Eventlog\System","Sources",0x10000,""
 HKLM,"System\CurrentControlSet\Services\Tcpip\Parameters","DataBasePath",,"%12%\etc"
1
  • Gentoo? Also, is the /etc/portage/ location specific to Gentoo? (I don't have that dir on my Ubuntu 20.04) In other words, would this answer not work for Ubuntu users? In that case, this answer would rather belong on e.g. the Unix/Linux SE. The stackexchange concept allows you to introduce a question first, and then post this information there as a self-answer. That way you can publish and preserve this information on the web, but in a place where it taxonomically would make more sense.
    – Levente
    Feb 23 at 16:49

You must log in to answer this question.

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