I want to run a Windows executable (a console application) from a shell script. This script is part of a bigger project that automatically builds packages, so I need to avoid user interaction.

Actually I use something like this:

export WINEARCH=win64
export WINEPREFIX=/somewhere/$WINEARCH
wine pgen.exe

It basically works but with with the following problems:

  1. If WINEPREFIX is empty (and this is the case in the first run), a dialog appears showing to wait for configuration. I'd like to avoid depending on an X server running.
  2. If not previously installed, wine shows a window asking to install Gecko and requiring user intervention.
  3. WINEPREFIX needs to be owned by the user calling wine, so I don't know how to provide a system-wide wrapper to run the above application.

Apart the latter issue (that I can live without), the other ones are blocking. At the end I just want to run a console application.

  • Try DOSBox (sudo apt-get install dosbox)
    – user104976
    Mar 4, 2015 at 17:24

2 Answers 2


If you run wine with an empty $DISPLAY, it will skip displaying any dialogs and run without user interaction:

DISPLAY= wine pgen.exe

To avoid the prefix ownership issue, I generally point WINEPREFIX at a temporary directory so the prefix is re-created every time (but that's slow).

  • Unsetting DISPLAYalso avoids to trigger other dialog windows: exactly what I was looking for.
    – ntd
    Mar 5, 2015 at 0:04

You can "boot" your wine environment by running it from an X session once, letting it configure mono etc. After that, backup the entire .wine directory and use that as a base for each user who needs to run the console application.

You can use xvfb as a virtual X server; see here for an example how to start it automatically. Then export DISPLAY=:1 before starting wine. I needed this to shut wine up about not having a display, even thouch I was only running a console executable. YMMV.

I'm not sure whether the WINEPREFIX tree needs to be owned by the user running wine, or just needs write permissions on certain locations (e.g. the .reg files, temporary locations).

  • Regardling the ownership I just retried and I can confirm you must own WINEPREFIX otherwise wine will refuse to start.
    – ntd
    Mar 4, 2015 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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