Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetEnvironmentVariable example will return the expanded paths #359

Open
jborean93 opened this issue Feb 20, 2019 · 0 comments
Open

GetEnvironmentVariable example will return the expanded paths #359

jborean93 opened this issue Feb 20, 2019 · 0 comments

Comments

@jborean93
Copy link

When using [System.Environment]::GetEnvironmentVariable("Path", "User"), the returned value will have an already expanded path. The line should get the raw registry value that does not have an expanded string to ensure that when the path is prepended with the WSL path, it still contains the expand placeholders.

For example, the default User path value is actually %USERPROFILE%\AppData\Local\Microsoft\WindowsApps;. The line above will return C:\Users\<username>\AppData\Local\Microsoft\WindowsApps and will replace the unexpanded string when we set it in the next command.

What this should be is;

$userenv = (Get-Item -Path HKCU:\Environment).GetValue("PATH", $null, "DoNotExpandEnvironmentNames")
[System.Environment]::SetEnvironmentVariable("PATH", $userenv + "C:\Users\Administrator\Ubuntu", "User")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant