If you are launching a Wine application from a terminal session, there are two or three things you have to do before installing and/or running an application from the command line:
1 | export WINEPREFIX=$HOME/myprefix | This is only needed if you're using a separate prefix for the application. |
2 | cd $WINEPREFIX/path/to/install/directory | Some applications may run without this step but many won't. Doing it never causes a failure. |
3 | wine myapp.exe [options and arguments] | Run the application, supplying and options and arguments it needs. |
Step 1 creates a prefix in your login directory called 'myprefix' instead of using the default, which is $HOME/.wine and, because you've created and exported the WINEPREFIX shell variable, Wine will use it rather than the default prefix when it runs the installer and the application.
Step 2 is required because of a design difference between Windows and the UNIX-derived operating systems, which include Linux and Apple's OS X. Windows applications expect to be run from the directory they are installed in, i.e. that this is the current directory when the application is started, and that configuration files, .DLLs, etc. will be found relative to this directory while user-created data files will be elsewhere. UNIX programs have a quite different expectation: that they will be run from the directory containing the user-created files, that the configuration files will be in /etc or /usr/local/etc and that DLLs will be found via a system-defined search path.
Of course, you need to repeat these steps each time your computer has been restarted, you've logged out and back in, or you've run some other Wine application in a different prefix. However, there is a way round this: use a wrapper script
A wrapper script is a tiny text file containing those three commands preceeded by a line that says the script is to be executed by the bash shell. It is created with your favourite text editor, typically gedit if you're using the Gnome desktop. Use the editor to create a file containing a four line script which, in this example, is called bin/runmyprog and runs an application installed in the .myprefix Wine prefix:
where bin is a directory in your login directory. '$*' passes any arguments used when the script is called to your program. Ignore it if the app never uses command line arguments.
Make the script executable with the command:
The script doesn't have to go in the bin directory, but by creating a bin directory and adding it to your search path you've kept things tidy and now have a place to put other, similar, scripts as you install more Wine applications. bin is, by convention, the name used in the UNIX world for the place where users keep scripts and programs they've written for their own use. It is short for 'binary', i.e. it is a place to keep binaries, a slang term for compiled programs.
NOTE: You should take a little care when choosing the name of this or any script you write. Obviously, the name should be meaningful so you won't forget it, but it must not be the same as any system command either. You can check for name clashes with the command "which scriptname". If which doesn't find a command with the same name it is generally safe to use it for your script. I usually name the prefix something like '.wine_appname' and call the script 'appname'.
Use the commands:
to create 'bin' directory. Everything to the right of the '#' is a descriptive comment and should not be typed in. Now edit .bash_profile, which is in your login directory, to include bin in your search path by adding the line:
after these lines:
You'll need to log out and log in again to make this change take effect.
Now you can launch your Wine app by typing the command "runmyprog" and hitting RETURN. The bin directory is automatically included in your search path whenever you're logged in as the user you used to install the Wine application and create the wrapper script, so it will be found and executed no matter what directory you're in at the time.
The process of creating an icon, if necessary, and setting up a launcher for the script is described in Adding an Icon for a WINE Application wrapper script.