Setting the default application to open PDF and EPUB files in Wine

I installed Wine on an Ubuntu Linux system to be able to run Microsoft Windows applications on it. I installed Sumatra PDF to view PDF and EPUB files. When I double-clicked on EPUB files in the Wine File Explorer window, which you can run by issuing the command wine explorer in a Terminal window, or wine explorer &, if you wish to open it and immediately return to the shell prompt, I saw an Error window which stated "There is no Windows program configured to open this type of file." If I double-clicked on a PDF file, it would open in the GNOME Document Viewer application. I was able to set the default application for opening those files under Wine with the following steps:

  1. From the Bash prompt in a Terminal window, run the Wine registry editor program to modify the Windows Registry with wine regedit.
  2. Navigate to HKEY_CLASSES_ROOT\.epub and set (Default) = epubfile. If you don't see a .epub entry, right-click on HKEY_CLASSES_ROOT and choose New. You can press the F5 key or choose View and Refresh to refresh the display to show the new entry in alphabetical order.

    Registry Editor - New Key

  3. If you then click on the .epub entry, you will see (Default) under Name, REG_SZ under Type, and (value not set) under Data.

    Registry Editor - .epub default

  4. Double-click on the entry and then type epubfile in the Value data field and then click on OK.

    Registry Editor - .epub epubfile

  5. Then navigate to HKEY_CLASSES_ROOT\epubfile\shell\open\command, if it exists. If there is no epubfile entry you can create one by right-clicking on HKEY_CLASSES_ROOT and selecting New and Key giving the new key a name of epubfile. Then double-click on the (Default) entry under the new key and type EPUB Document in the Value data field. Then right-click on the epubfile key and choose New and Key and type shell for the name. Right-click on shell and create a new, open beneath it. Then right-click on open and create a new key, command beneath open.

    Registry Editor - command key

  6. Then right click on the command key and choose New then String Value.

    Registry Editor - command key
New String Value

  7. Double-click on the new (Default) entry under command and then type the location and file name for the application that you wish to use to open .epub files within double quotes followed by a space and then "%1", e.g. "C:\Program Files\SumatraPDF\SumatraPDF.exe" "%1", if you wish to open the files with Sumatra PDF and you installed it so that it is accessible to all users of the system. Or use "C:\users\username\AppData\Local\SumatraPDF\SumatraPDF.exe " "%1", where username is the relevant username, if you chose to install it just for the current user when you installed it.

If you've taken the above steps and then double-click on a .epub file and see an "Invalid handle" error window, check to ensure that you've correctly entered the location for the executable file. You can locate it through the Wine File Explorer application.

If you wish to change the default application that opens PDF files under Wine to the same application as for EPUB files, you can navigate to HKEY_CLASSES_ROOT\pdffile\shell\open\command and change the (Default) data value from "C:\windows\system32\winebrowser.exe" "%1" to the same value as you used for epubfile.

If you only want to open a file with a particular application temporarily without making a permanent change to the application that opens a particular file type, you can use a command in the form below:

wine start 'C:\path\to\app.exe' 'C:\path\to\file.pdf'

Note: enclose the paths to the files, both the application and the file to be opened, within single quotes as the backslash character has a special meaning — it is an escape character — if it is not within single quotes. If you use double quotes, each instance of the backslash character must be preceded by another backslash to "escape" its special meaning. E.g.:

wine start "C:\\path\\to\\app.exe" "C:\\path\\to\\file.pdf"

E.g., to open a PDF file with SumatraPDF when that application is installed just for a particular user, I could use a command like the one below:

alice@Wonderland:~$ wine start 'C:\users\Alice\AppData\Local\SumatraPDF\SumatraPDF.exe' '\home\alice@Wonderland\.wine\drive_c\users\alice@Wonderland\Documents\ReadersNotebook.pdf'