How to elegantly create a Windows shortcut start starts a WSL program under X

  windows, windows-subsystem-for-linux, x11

I’m struggling a little to launch xfce4-terminal from my WSL installation under VcXsrv from a button on the Windows taskbar. I don’t want any DOS box/console/terminal other than the xfce4-terminal when I’m done. I have it working, but man is it ugly. Does anybody have a cleaner way of doing this?

Here is what I got working: I created a windows shortcut on the Desktop with this target (all in one line, broken with newlines for readability here):


startTerminal.vbs was inspired by from 10 Ways To Run Batch Files Silently And Hide The Console Window • Raymond.CC (one of the few solutions that didn’t require installing a separate program for this!) and it contains:

CreateObject("Wscript.Shell").Run "C:WindowsSystem32wsl.exe -u peter --exec /home/peter/bin/windows/",0,True

and contains:

export DISPLAY=localhost:0.0
xfce4-terminal --command=/bin/zsh

Setting DISPLAY is apparently required, even though I set the DISPLAY environment in ~/.zshrc. wsl.exe apparently doesn’t do that unless you run the login shell.

Once all of this is working, I can drag my shortcut to the taskbar and click on it there.

I count 3, three files cooperating to achieve this simple goal? Can I limit that to one or two without installing an external program?

Source: Windows Questions