Whether you use Wine to run critical business applications or just play a bunch of fun games that are only available for Microsoft Windows, Wine will actually start to register file associations for the different extensions that Windows programs use. You might not want to have old ones from programs you’ve uninstalled lying around, and you might actually have some problems with ones that Wine associates by default. If another program creates a file with a coincidentally identical file extension, then you might have a bit of a weird conflict if you try and double-click on it.
Fortunately, it’s actually easier to get rid of them than you might think. Keep in mind that this following process does reset the extension associations in your file manager, so you don’t want to do so if you find some of Wine’s useful. That being said, Wine will actually often recreate them when you use a program again. This also won’t be a problem if you use the File menu to open files from inside of Wine. More than likely, you aren’t running any critical enterprise applications through Wine anyway, so for most users that seem to be an issue.
Method 1: Removing Wine File Associations Permanently
You’ll need to start by opening up a terminal window. Search for the word Terminal on the Ubuntu Unity Dash or click on the Applications menu and then find it in System Tools. Since this process only involves manipulating files inside of your own home directory, you won’t need administrator access for it.
To remove all of the file associations in one fell swoop, first type
rm -f ~/.local/share/applications/wine-extension*.desktop
and then push enter followed by typing
rm -f ~/.local/share/icons/hicolor/*/*/application-x-wine-extension*
and a second enter button push. The first command removes all of the Wine extension .desktop files that Windows programs have created while the second clears out any icons that Wine might have associated with them.
If you ever see seemingly random weird red wine glasses as icons for some files, then this will also solve that problem. It’s caused by having file types associated with Wine when Wine doesn’t have any actual icon for them. The red glass is a joke reference to the name of the Wine program, but this joke reference will sometimes trip up new users because it’s not exactly the most intuitive thing off the bat. The rule of thumb is if you have anything featuring a wine glass on top of an icon, then it’s a jokey Linux way of telling the user that a file is associated with Windows code that executes through Wine.
You’ll next have to remove the old cache with three commands. Type
rm -f ~/.local/share/applications/mimeinfo.cache
rm -f ~/.local/share/mime/packages/x-wine*
and then finally
rm -f ~/.local/share/mime/application/x-wine-extension*
all as separate commands. Once you get to this point, there’s no turning back so you’ll want to make sure you really want to do this before you proceed. While this won’t actually do any irreversible damage, if you remove file associations without really meaning to it can be a bit annoying. Once again, though, Wine’s programs will usually recreate them when you run them.
Update the cache by issuing
as two separate commands. You’ll more than likely have a number of new default Linux file associations again. This should be all that you have to do in order to get rid of them, so this is useful if you’ve just got rid of an old program you don’t use anymore and want rid of the associations that are related to it. This does remove all of the various other file associations that Wine created as well, but if you’re not using a VBScript interpreter then this simply isn’t going to be much of an issue at all. You’ll need to recreate Windows Hosting associations if you use VBScript or Microsoft JScript programs, but these associations will repair automatically anyway. Besides, you’re probably using shell scripts to do anything you’d want to with Wine.
You may want to do this after uninstalling certain games, by the way. There are some older Windows game programs that associate many different proprietary file extensions with the program itself so you might want to do this in order to keep that all cleared out.
Make sure to never run these commands unnecessarily, though, since they really will reset the MIME types that Nautilus, PCManFM, Thunar and other file managers use to associate different extensions with different programs. On the other hand, though, the process might actually make things faster since you won’t have to look through so many of them when opening up something you were looking at.
Method 2: Restore Help Associations
If you use Wine to read electronic books in CHM format, then you won’t have to worry. Simply right-click on a CHM file, click on Open With and then type wine hh in the box that reads “Command line to execute:” so that it loads the default wine CHM viewer. To save this association again, type a name in the Application name box and click on “Set selected application as default action for this file type” to keep it permanently.
You won’t have to do this if you don’t use CHM files or open them with a native Linux browser. While an increasingly large number of IT manuals actually get published under the PDF format these days, you may want this functionality to read help files or coding manuals from older versions of Windows applications. There are also browser extensions available for Firefox that you might want to look into if you’re interested in continuing to be able to read these files without having to install Wine to begin with. That would solve the issue of file associations altogether if you’re only using Wine as this kind of viewer.