Ubuntu – Force file extension to open with specific app (Extensions like .exe, .jpg, .mp4…)

file formatnautilus

I have already read the question about Creating .desktop files to use on the "Open with other application" tab but this is not what I want, I want to be able to click on the file in Dash or in Nautilus and be able to open it with the specified app.

For example I have this case right now:

When I click on an EXE file it does not get executed by Wine, instead I get the following:

If I try to look for Wine in the Open With context menu option it is there. I am fine executing it from there the first time, but then the following times Wine does not appears selected in the main Context menu:

I then went to Properties to the Open With Tab to look for Wine. It was not in the Default apps nor was it in the Recommended ones when I clicked and search on Show other applications

This is not limited to EXE extensions. It also has happened with MKV files, MP4 files, JPG, PNG, MP3 and even SVG and CSS. So instead of trying to find a way of solving it for one, I want a way that can be done to any type of extension that can:

• Make the app the default of that extension
• Appear on the context menu in Nautilus when I right click on the file
• Appears on the "Open With" tab on the Property window of the file
• Correctly executes the specified app when I click on the file with Dash

This might sound like it should be common sense for an app to execute the file but it does not always work like that. So for the cases where it actually does not work, how to fix it. A reset of the extension?, An update of the files that can open said extension?, an addition of the app via a command line or GUI tool?

You can use the command mimeopen, in a terminal go to the folder where your .exe file is and type
mimeopen -d filename.exe
You will get a popup menu, where you can see some options, but there is also an option 'Other...', choose this one, then type the command which you would use if you would open the file in the terminal and replace the filename with %f. So in this case you would type wine %f.