Ask Your Question
0

Can Windows environment variables in WSL be obtained?

asked 2023-07-12 23:41:38 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-07-12 23:59:02 +0000

devzero gravatar image

Yes, Windows environment variables can be obtained and used within WSL environment. They can be accessed through the /mnt directory, where the Windows files system is mounted. For example, the value of the USERNAME environment variable can be obtained by running the command echo $USERNAME in the WSL terminal.

To access other Windows environment variables, prefix them with $env: in PowerShell and use them as usual. For example:

$env:APPDATA 

This will show the path to the current user's application data folder in Windows.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-12 23:41:38 +0000

Seen: 10 times

Last updated: Jul 12 '23