7

I want to install Wine only for running a program, but I don't want to open any other Windows file (for security). Is it possible to ensure Wine does not execute .exe files automatically? Thank you.

1
  • Why do you focus on Windows executables? Any executable file or executable shell script can be run with /path/to/executable or ./executable. Linux executables aren't magically more secure than Windows executables, especially when the latter run on Wine! Sep 24, 2013 at 23:13

7 Answers 7

4

When you install the wine package, it registers itself so that .exe files, if run from the command line, will "auto run via wine" if they match a specific signature and have executable bit set (like via chmod +x).

To prevent accidental direct execution of exes from console like

/path/to/program.exe

you can setup binfmt_misc kernel module with the following command:

sudo update-binfmts --disable wine

This will disable support for direct execution of files with magic MZ.

CAVEAT: this appears to be undone on restart or Wine upgrade.

If you really want to get rid of it (until wine upgrade!), run

 sudo update-binfmts --package wine --remove wine /usr/bin/wine
1
  • 1
    This should be the accepted answer
    – crobar
    Oct 4, 2017 at 14:44
3
+50

Wine does not run files automatically (poor wording choice on your part).

However, if you want exe files to open with something else by default, you need to change the associated program for exe files to something other than Wine (you can do this from the properties window in Nautilus).

To run your program, you can create a .desktop file or simply use "Open With" from the context menu.

4
  • I wouldn't believe it unless I'd seen it, but if I open a console and cross compile "a.exe" then run it, like $ ./a.exe voila, wine appears and runs it for me. It is bizarre...
    – rogerdpack
    Sep 24, 2013 at 0:11
  • 1
    That occurs because wine is set (by binformat support) to run exes when you attempt to execute them. I don't know if that can be disabled without removing wine though. BTW, your question is vague if that is what you mean.
    – RolandiXor
    Sep 24, 2013 at 3:15
  • 2
    Ok looks like the binfmt-support in question can be disabled via sudo update-binfmts --disable wine (you can see its list via update-binfmts --display) thanks for the tip. Finally it doesn't auto run my console exe's, which can be problematic when cross compiling.
    – rogerdpack
    Sep 27, 2013 at 18:46
  • update-binfmts needs the binfmt-support package, not installed by default packages.debian.org/pt-br/sid/binfmt-support Dec 22, 2014 at 14:49
3

As far as I know, wine does NOT execute .exe files by default, based on my experience so far with Wine on Ubuntu 13.04.

I'm not sure if previous Ubuntu/Wine versions allowed it automatically run executables, but at least you can be fairly certain that that is not currently the case.

2
  • With 12.10 it certainly does...is there any way to disable it though?
    – rogerdpack
    Sep 23, 2013 at 22:48
  • With 13.04 it also (for me anyway) wine runs an exe files if you double click them in unity file explorer, and also if you run them in the command line like "./a.exe" it automatically invokes wine to run it for you.
    – rogerdpack
    Sep 27, 2013 at 18:42
1
  1. Wine doesn't associate with .exe files by default on most systems, and depending on your installation, it 'may'.

    The EASIEST way for you to do this would be to install the program Ubuntu Tweak, this can be downloaded from here: Ubuntu Tweak Download Instructions

    Once you have it downloaded you simply open it up, change to Admins tab and then under System choose File Type Manager. Once in here select the file category Text and using shift-click and/or control-click select all of the file types you want, then click Edit on the bottom right.

    This will allow you to multi-set the mimetype opener for all of the files.

    See screen:

    https://i.stack.imgur.com/BZtGN.jpg

  2. I believe that this is what you need in addition to the above point: How to prevent Wine from adding file associations?

Ref: how can I change file association globally?

3
  • Nice! I think this does work for the file explorer so that double clicking an .exe file doesn't automatically run it, which is nice, thanks!
    – rogerdpack
    Sep 27, 2013 at 18:47
  • @rogerdpack If it works for you, please accept the answer by clicking the green 'tick' icon so that those who visit the Q in future know what to try first. Thanks. :-)
    – TomKat
    Sep 28, 2013 at 4:48
  • Unfortunately I am not the original asker of the question...
    – rogerdpack
    Sep 30, 2013 at 15:26
0

Wine doesn't run .exe files by default unless you add such an association rule. If you did, remove it from Nautilus properties.

0

One option is to rename your wine executable, ex:

 sudo mv /usr/bin/wine /usr/bin/wine.disabled

or the like. Just remember to remove that or rename it if you remove the wine package :)

Sometimes configure scripts will still use "wine64" if it's present (and update-binfmts might not be enough of a work around), so you may need/want to rename that as well.

0

I found the best way in the man page for binfmt.d. To override a rule, create a symlink in /etc/binfmt.d to /dev/null with the same name. In the case of wine, the package file is at /usr/lib/binfmt.d/wine.conf and can be overridden with

sudo ln -s /dev/null /etc/binfmt.d/wine.conf

This change is permanent and will survive reboots and wine updates.

2
  • Yes that's probably right, but a "sudo" in front of it still would not hurt, so I don't get the "musn't" part. Apart from that, my comment seems to have disappeared, it was just saying to add sudo.
    – Tasnad
    May 24, 2019 at 11:23
  • I have modified it... relax. May 24, 2019 at 15:41

You must log in to answer this question.

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