I remember Cygwin always inherited Windows environment variables in bash session. In WSL world, there’s another way via WSLENV and it’s explained below.
“WSLENV” to enhance environmental variable interop between Win32/WSL
Share Environment Vars between WSL and Windows – Windows Command Line
If you don’t need to reference Win10 env. var. often from WSL, maybe using powershell.exe like below is good enough.
$ powershell.exe -command 'echo $Env:APPDATA'|tr -d '\r' C:\Users\kinoue\AppData\Roaming
As an example, this is how to backup Office365 MS-Word global template file Normal.dotm.
$ cp -p $(wslpath $(powershell.exe -command \ 'echo $Env:APPDATA'|tr -d '\r'))/Microsoft/Templates/Normal.dotm{,.backup} $ command ls -l $(wslpath $(powershell.exe -command \ 'echo $Env:APPDATA'|tr -d '\r'))/Microsoft/Templates/Normal.dotm* -rwxrwxrwx 1 kinoue kinoue 19229 Jul 24 2018 /mnt/c/Users/kinoue/AppData/Roaming/Microsoft/Templates/Normal.dotm -rwxrwxrwx 1 kinoue kinoue 19229 Jul 24 2018 /mnt/c/Users/kinoue/AppData/Roaming/Microsoft/Templates/Normal.dotm.backup
One thought on “Using Windows env var %APPDATA% in WSL”