You can create a batch file for automatically launching WSL and Linux GUI desktop on X410. The following describes steps for creating such a batch file.

STEP 1 Install a Linux GUI desktop

There are various GUI desktops for Linux. In this example, we’ll be installing Xfce4 on Kali Linux (WSL). On the Kali Linux command prompt, execute the following commands and simply install the ‘kali-desktop-xfce‘ package already prepared by Kali Linux team:

sudo apt update && sudo apt -y upgrade
sudo apt -y install kali-desktop-xfce

STEP 2 Create a batch file

@echo off
start /B x410.exe /desktop
kali.exe run "if [ -z $(pidof xfce4-session) ]; then export DISPLAY=; xfwm4& xfce4-session; pkill '(gpg|ssh)-agent'; fi;"

• x410.exe /desktop

x410.exe launches X410. When "/dektop" is passed as a command line argument, X410 is launched in "Desktop" mode. If X410 is already running in "Windowed Apps" mode, it’ll be shutdown and started again in "Desktop" mode.

If you want to launch X410 in "Windowed Apps" mode, you should use the "/wm" command line argument. If you don’t specify either argument, X410 will be in the same mode as the last time it was used.

• $(pidof xfce4-session)

"pidof xfce4-session" Linux command returns the process ID of running xfce4-session (Xfce4 Session Manager). Hence the if [ -z $(pidof xfce4-session) ]; then ensures executing the following commands (i.e., export DISPLAY=…) only when the Xfce desktop isn’t already running.

Please also note that the "xfce4-session" doesn’t have an ‘&’. If you append an ‘&’ (i.e., xfce4-session&), it’ll be pushed to background and the kali.exe will be terminated immediately. Such termination also terminates the GUI apps running in background as their parent Bash shell (= internally launched by the kali.exe) has exited.

Thus in order to prevent such terminations and keep the Xfce desktop running, you should not append an ‘&’.

• pkill ‘(gpg|ssh)-agent’

When xfce4-session is launched, it automatically tries to start ssh-agent and gpg-agent.

Those agents can still be running even after terminating the xfce4-session. In order to terminate the agents since they are no longer needed or used, pkill ‘(gpg|ssh)-agent’; is added.

If you want to stop xfce4-session from ever launching those agents, you can use the following commands:

xfconf-query -c xfce4-session -p /startup/ssh-agent/enabled -n -t bool -s false
xfconf-query -c xfce4-session -p /startup/gpg-agent/enabled -n -t bool -s false

When you close X410, xfce4-session also gets terminated along with the batch command window and WSL.

Automatically Closing X410 When You Logout

When you select the ‘Logout’ menu from Xfce desktop, it only terminates the Xfce; X410 will be remained open. If you want to automatically terminate X410 as well, you can use the ‘taskkill‘ command. The ‘taskkill’ is a Windows command, but since we’re in WSL, we can also use it from the Linux shell. So instead of adding it directly to the batch file, we can add it after the ‘pkill’ command:

@echo off
start /B x410.exe /desktop
kali.exe run "if [ -z $(pidof xfce4-session) ]; then export DISPLAY=; xfwm4& xfce4-session; pkill '(gpg|ssh)-agent'; taskkill.exe /IM x410.exe; fi;"

Hiding the Batch Command Window

You cannot completely hide the batch command window. However, you can minimize the window by creating a shortcut:

Pin a Batch file to Start and/or Taskbar

You cannot pin a batch file in Windows 10 (yet?). However, there is a workaround. Instead of creating a shortcut for the batch file, create a shortcut for the cmd.exe (Windows Command Prompt) and pass the batch file as its command line argument with ‘/C’ (= carries out the command and terminates). For example, instead of "C:\Users\choung\Desktop\Kali Linux.bat", set the ‘Target’ as %windir%\system32\cmd.exe /C "C:\Users\choung\Desktop\Kali Linux.bat". Once the Target is changed, you can ‘Pin to Start‘ or ‘Pin to taskbar‘ from its right-click popup menu.