On my quest to make my WSL Windows Toolbar Launcher working, I found out that my attempt to set environmental variables for WSL from within command prompt futile:

Within command prompt, I can do a wsl export DISPLAY=, but wsl echo $DISPLAY or printenv DISPLAY will return nothing.

Is querying or even setting WSL environmental variables even possible from within command prompt?

P.s. In my case, I have those set in my .bashrc but running a script via wsl seems to have done nothing to the variables, as the GUI does not forward to the X-server on Windows 10 (host).

1 Answer 1


I only know of one environment variable that is passed between WSL and the Command Prompt: WSLENV.

For WSLENV to be passed, one must invoke the other, meaning that a WSL session invokes cmd.exe, or that a cmd.exe session invokes ubuntu (or another distribution).

For more information, see the Microsoft article
Share Environment Vars between WSL and Windows.

You must log in to answer this question.

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