Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I actually want to ask two questions:

  1. Where can I find more about available arguments/parameters shortcuts for Exec entry in desktop files (like %U, %u, %f...)

  2. Main question, how to pass file as argument on .desktop launcher for wine application?

I found searching here this suggestion: z:%f which is of no use to me, as if I simply run .desktop file without passing file on it, it assumes that argument is z: and starts scanning z: "drive"


[Desktop Entry]
Name=Some Windows program
Exec=wine "program.exe" z:%f

I want to drop XML file on my custom .desktop launcher for this wine application and I can this way. Problem is that if I click on launcher icon to evoke this program, argument z: is always passed on it and that's not acceptable

share|improve this question
What are you trying to do btw? Can you add an example? – Bruno Pereira Dec 10 '11 at 22:10
Hey Bruno ;) I thought it is clear - I made desktop file (purpose - launcher) for wine application and I want to be able to pass file on it. Above z:%f workaround is no good as whenever I launch this wine application argument z: is passed on it and I want to avoid that – zetah Dec 10 '11 at 22:18
So you have a windows program called (ie) application.exe that you want to pass the current selected file in nautilus to it ie file.txt? – Bruno Pereira Dec 10 '11 at 22:32
Sorry I should have added example in my first post. I added it now – zetah Dec 10 '11 at 22:39
I have been having a look around this till now and the only other option for this is a script placed in the exec line that checks for a %f, if it exists launch the application on the file, if not just launch the application. Care for it or is it not an option? – Bruno Pereira Dec 11 '11 at 1:03

This is best I can so far (Notepad example)

[Desktop Entry]
Exec=sh -c "echo %f | sed 's/^\//z:\//' | xargs wine /home/zetah/.wine/drive_c/windows/notepad.exe"

I expect better answers considering I'm beginner

share|improve this answer
See my improvement below for passing multiple files. – Harvey Dec 2 '14 at 6:47

For the first question, you can take a look at the Desktop Entry Specification - The Exec key

share|improve this answer
Thanks, I found it already: – zetah Dec 11 '11 at 12:21

There were lots of hackish solutions posted in this thread. Here's a much better solution that deals with multiple files and with spaces in filenames.

Create the .desktop file as you usually do, and simply use this Exec line:

Exec=/usr/bin/env bash -c "printf 'z:%%q\\n' %F | WINEPREFIX='/home/<your username>/.wine' xargs wine 'C:\\Path\\to the executable\\app.exe'"

Edit: If your application can handle multiple files in a single instance (for example a multi-tabbed PDF viewer) and you want the current instance to be auto-focused whenever you launch a new file then you need to do the following:

  • Add this line to the .desktop file: StartupWMClass=app.exe

  • Use this Exec command:

    Exec=/usr/bin/env bash -c "(printf 'z:%%q\\n' %F | WINEPREFIX='/home/<your username>/.wine' xargs wine 'C:\\Path\\to the executable\\app.exe' &); xdotool windowactivate \$(xdotool search --sync --onlyvisible --class \"app.exe\")"
share|improve this answer

This is the way that just worked for me on a RHEL 6.3 box after some trial and error and reading the Desktop Entry Specification. It's not specific to wine with arguments but it should work with something like Exec=wine \"filename.exe\".

Hope it helps someone as it took me some searching to get it to work.

I think you have to use double quotes and escape them as well as any special characters using a backslash.

[Desktop Entry]
Name=Ansys User Lic Prefs 12.1
GenericName=Ansys User Lic Prefs 12.1
Comment=Ansys User License Prefs 12.1
Exec=anslic_admin \"\-userprefs121\"
share|improve this answer

An improvement on zetah's answer. This works for passing multiple files to the program. The %f is changed to %F (upper case) to pass all the files dropped, replacing the ^ (for the beginning of the line) with enough of the path name to make it more likely unique, the 'g' at the end of the sed command to cause the replacement to repeat for all files passed and finally the $ instead of the / so that the \ escape characters are not necessary.

Exec=sh -c "echo %F | sed 's$/home$z:/home$g' | xargs wine /home/owner/.wine/dosdevices/c:/Progs/Boxer/b.exe"

I also moved the program to be executed to a path where the pathname has no spaces, so I moved my boxer editor from:

/home/owner/.wine/dosdevices/c:/Program Files/Boxer Text Editor/


share|improve this answer

I just wrote a tiny Python script which converts Unix-style paths into Wine path format.

Download the zip, extract into your home folder and edit your .desktop file like this:

Exec=python ~/ "program.exe" %F
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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