Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 10 down vote accepted
+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.

share|improve this answer
    
Thanks a lot. This clearly is the better solution! –  mniess Jan 7 at 16:19

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

share|improve this answer
    
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 '13 at 16:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.