1

After updating Ubuntu to 22.04, PlayOnLinux does NOT work to install nor to run any Windows apps, so I had to research and I found the wine command that is a great alternative not only to run any app but also to install just typing in Terminal:

$ wine setup.exe.

After the installation following the steps from this website without installing about winehq because of this, I have to type the following commands every time when I want to play, it's very tiring:

$ cd /home/<user>/.wine/drive_c/Program\ Files\ \(x86\)/<folder_of_app>

$ wine <file>.exe

So I have one idea to make a desktop shortcut with the commands that runs automatically after I clicked it by a mouse.

Could anyone help me?

3
  • Install VirtualBox, install Windows in VirtualBox. You can then create a desktop icon for that virtual machine. Oct 26, 2022 at 11:51
  • @C.S.Cameron Making a desktop shortcut with VirtualBox is more complex than making two simple files of .sh and .desktop as the explanation in my answer.
    – luisito_36
    Oct 26, 2022 at 17:02
  • One method will run AutoCAD and Solid Works and the other won't. Oct 27, 2022 at 2:46

1 Answer 1

-2

UPDATED 4 NOV 2022: Lately, I figured out how to make a Desktop Shortcut to run an .exe file depending on what kind of applications for Windows, for example:

  • If a simple app like notepad.exe, ultraiso.exe or other apps that runs with a simple window without a full screen, it needs only one .desktop file to run: Follow the point A and C.
  • If an app that runs with a full screen like "Need For Speed High Stakes" or "Age of Empires II HD", it needs two files with the different extensions .sh and .desktop to run: Follow the point B and C.

A. Make a new Desktop shortcut archive with the .desktop extension in the Desktop directory /home/<user>/Desktop/, and also in "all applications" directory /usr/share/applications/, copy/paste the following text in it:

  • Note: Between the quotation marks next to wine, it needs double backslash \\ to separate directories of a path.
[Desktop Entry]
Name=<name>
Comment=<comment>
Keywords=<word1>;<word2>;<word3>
Exec=wine "C:\\Program Files (x86)\\<app_folder>\\<file>.exe"
Terminal=false
Type=Application
StartupNotify=true
Icon=<icon>
  • If you want to execute any wine configuration like winecfg, then copy/paste this Exec syntax instead:

Exec=wine <configuration> %f

CONFIGURATION       DESCRIPTION

winecfg             Wine configuration
control             Wine Control Panel
control joy.cpl     Game Controllers
regedit             Registry Editor
uninstaller         Add/Remove Programs

B.1. Make a new shell script archive with the .sh extension in the main folder of the application installed, copy/paste the following shell script text in it:

gnome-terminal --tab --title="<name>" --command="bash -c 'cd /home/<user>/.wine/drive_c/Program\ Files\ \(x86\)/<app_folder>; wine <file>.exe'"

The meaning of each one of shell script:

SYNTAX              DESCRIPTION

gnome-terminal      Open up a gnome-terminal

--tab               Open up a unique tab

--title="<name>"    Name (whatever you want) of a tab

--command="bash -c '<cmd1>;<cmd2>;<cmd3>'"
                    The (bash -c) syntax is a bash command that runs the first
                    <command>, once it is finised, it runs the next <command>
                    and so on.

B.2. Make a new Desktop shortcut archive with the .desktop extension in the Desktop directory /home/<user>/Desktop/, and also in "all applications" directory /usr/share/applications/, copy/paste the following text in it:

[Desktop Entry]
Name=<name>
Comment=<comment>
Keywords=<word1>;<word2>;<word3>
Exec=/home/<user>/.wine/drive_c/Program\ Files\ \(x86\)/<app_folder>/<file>.sh
Terminal=false
Type=Application
StartupNotify=true
Icon=<icon>
  • Note: If Terminal launched by a .sh file does NOT run an app in several seconds, to solve the problem is to press CTRL+C to stop Terminal and it closes automatically. And then, try again the same way to run an app. WARNING ! Never, ever close Terminal by user, it could kill Terminal and it will NOT work FOREVER until the user has to format the hard disk and reinstall Ubuntu.

C. Set the .desktop archive to be executable and allowed to launch, also set the .sh archive to be executable:

  • Note: If the Desktop shortcut or the Desktop directory is set to be writeable for OTHER users, the Desktop shortcut could be blocked to launch.

Setting a file/folder to be executable for USER (owner), is to type u+x; Removing a file/folder to be writeable for OTHER, is to type o-w; This is an example of the command in Terminal to set or remove executable or writeable:

$ chmod -v u+x <file/folder>

Setting a <file>.desktop to launch in the Desktop directory:

$ gio set <file>.desktop metadata::trusted true

Check if it's allowed to launch:

$ gio info <file>.desktop | grep metadata::trusted

D. About getting the icon file to the Desktop shortcut, there are two kinds to choose:

  • The code of the icon (The code of every different icon is in every file in /usr/share/applications): Icon=<code_of_icon>
  • Getting from any file of PNG: Icon=/<path>/<file>.png

That's all, best regard.

8
  • 2
    I'm pretty much sure you messed up in your "script theory". I've seem many direct executable files in Linux and no you don't need two files to do the task of one! Try to set "arguments" to your command line, if it's no there, try to set the whole command in that shortcut. A pretty common task in programming daily skills is to "set arguments to your command lines" Oct 26, 2022 at 3:48
  • 1
    i think you can run exe on Exec without cd nor sh script.
    – Sad3ng
    Oct 26, 2022 at 6:32
  • @SatoshiNakamoto, This is the best and easiest way that I figured out how to and I tested before posting my answer. Furthermore, to click with a mouse, is to any .desktop file not a .sh file; to open a .sh file, you have to open Terminal and type ./file.sh.
    – luisito_36
    Oct 26, 2022 at 16:29
  • 1
    @Sad3ng, Linux does NOT run any .exe file without the wine command, in addition wine does NOT work to run .exe with a path directory, for example to type in Terminal wine /home/user/path/file.exe it doesn't work at all. So you first have to type cd /home/user/path/ and then wine file.exe. On the other hand, how do you run .exe without a .sh file? How do you add wine in the .desktop file to run any .exe file?
    – luisito_36
    Oct 26, 2022 at 16:33
  • @luisito_36 you can use WINEPREFIX to remember of wine to run .exe path.
    – Sad3ng
    Oct 26, 2022 at 16:40

You must log in to answer this question.

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