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

  • What are you trying to do btw? Can you add an example? Dec 10, 2011 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, 2011 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? Dec 10, 2011 at 22:32
  • Sorry I should have added example in my first post. I added it now
    – zetah
    Dec 10, 2011 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? Dec 11, 2011 at 1:03

7 Answers 7


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


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


An Exec line with a pipe of winepath to xargs, used with proper quoting and their -0 options, works flawlessly in Ubuntu 14.04 for opening single and multiple files.

Exec=/usr/bin/env sh -c "winepath -w -0 %F | WINEPREFIX='/home/your_user_name/.wine' xargs -0 wine 'C:\\\\Program Files\\\\Some Vendor\\\\SomeProgram.exe'"
  • Old thread, but for anyone walking in here from google in 2023, this is the solution that worked for me. The other answers on this page would not even run my application.
    – Partack
    Feb 9 at 19:05

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/



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

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

Exec=python ~/wine-launcher.py "program.exe" %F

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\")"

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\"

You must log in to answer this question.

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