Install Kali Linux Desktop on Windows with WSL2
Win-KeX Features
Install Kali Linux on Windows
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft Windows subsystem Linux /all /norestart
wsl --set-default-version 2
Install Win-KeX
sudo apt update && sudo apt install -y kali-win-kex
Start Win-KeX
kex --win
kex --sl
Win-KeX Start Examples
kex - Desktop full screen
kex --win - Desktop Window
kex --sl - Desktop Seamless Mode
kex --sl -s - Desktop Seamless Mode with Sound
kex --sl --wtstart - KeX server and win-kex client in terminal
kex --esm - KeX desktop in native RDP windows
Prerequisite for Win-KeX
Linux Shell in Windows Terminal
Troubleshooting
If VcXsrv is trying to start Win-KeX in Seamless Mode, an error is issued by VcXsrv:
A fatal error has occurred and VcXsrv will now exit.
In the log, it’s the last lines in /tmp/win kexsl_user.log:
winMultiWindowXMsgProc - Fatal error 1 on xcb connection
winClipboardIOErrorHandler!
winClipboardProc - setjmp returned for IO Error Handler.
(II) Server terminated successfully (0). Closing log file.
here you can try to start Win-KeX with sudo:
sudo kex --sl --wtstart -s
A solution also brought the deletion of the logs under /tmp.
sudo rm -f /tmp/*.log
And stop the KeX server with the –stop and –kill option.
sudo kex --stop
sudo kex --kill
After that, the start of kex as a normal user became possible.
kex --sl --wtstart -s
Also, a Win-KeX reinstallation can fix the error:
sudo kex --stop
sudo kex --kill
sudo apt-get purge kali-win-kex
sudo apt-get install kali-win-kex
sudo apt-get install dbus-x11
The Win-KeX help can also be useful.
kex --help
        Win-Kex 2.10 provides a GUI desktop experience for Kali Linux
        in Windows Subsystem for Linux 2 (WSL 2)
        Usage:
                kex <mode> <command> <parameters>
                Mode:
                --esm            : Launch KeX desktop in a dedicated window using Windows native RDP
                --sl             : Seemlessly integrate KeX into the Windows desktop
                --win            : Launch KeX desktop in a dedicated window
                Command:
                [none]           : start KeX server and launch KeX client
                --start          : start kex server
                --start-client   : start kex client
                --stop           : stop kex server
                --status         : show kex server status
                --kill           : stop kex server and kill all related processes
                --passwd         : set kex server password
                --wtstart        : start kex server and launch win-kex client
                                   in Windows Terminal session
                --start-sound    : start Windows sound server
                --stop-sound     : stop Windows sound server
                --help           : display help
                --version        : display version
                Parameters:
                -i               : Use container IP address instead of "localhost"
                -m               : Optimized for Multiscreen (Win mode only)
                -s               : Sound support
        Examples:
                kex -s           : Start KeX server in window mode and launch KeX client with sound support
                kex --sl -s      : Start KeX in seemless mode and launch KeX client with sound support
                kex --esm -i -s  : Start KeX in ESM mode with arm workaround and launch KeX client with sound support
                sudo kex         : Start KeX server as root in window mode and launch KeX client
	