Skip to content

Instantly share code, notes, and snippets.

@irizwaririz
Created March 28, 2022 14:02
Show Gist options
  • Save irizwaririz/6ac50dc20f22836a8bb48422973c8bbc to your computer and use it in GitHub Desktop.
Save irizwaririz/6ac50dc20f22836a8bb48422973c8bbc to your computer and use it in GitHub Desktop.
Batch script to instantiate Xserver
@echo off
start "" "C:\Program Files\VcXsrv\vcxsrv.exe" :0 -multiwindow -ac
@irizwaririz
Copy link
Author

irizwaririz commented Sep 28, 2022

NOTE: For WSL2, it might already use WSLg. So to disable it, add the following entry in the .wslconfig file (located at c:\users\MyUser\.wslconfig). This will turn off support for GUI applications in WSL.

[wsl2]
guiApplications=false

Sources:
https://github.com/microsoft/wslg#wslg-system-distro
https://www.reddit.com/r/bashonubuntuonwindows/comments/tc42tq/comment/i0daxht/?utm_source=share&utm_medium=web2x&context=3

Then we will need to set the DISPLAY environment variable as such:

export DISPLAY=$(route.exe print | grep 0.0.0.0 | head -1 | awk '{print $4}'):0.0

Source:
https://stackoverflow.com/a/66398613

@irizwaririz
Copy link
Author

You might also encounter firewall issues when doing this with WSL2, refer to this on one way to solve the firewall issue:
https://www.youtube.com/watch?v=4SZXbl9KVsw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment