I have found out that setting the PATH environment variable affects only the old command prompt. PowerShell seems to have different environment settings. How do I change the
You can also modify user/system environment variables permanently (i.e. will be persistent across shell restarts) with the following:
Modify a system environment variable
[Environment]::SetEnvironmentVariable
("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)
Modify a user environment variable
[Environment]::SetEnvironmentVariable
("INCLUDE", $env:INCLUDE, [System.EnvironmentVariableTarget]::User)
Usage from comments - add to the system environment variable
[Environment]::SetEnvironmentVariable(
"Path",
[Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";C:\bin",
[EnvironmentVariableTarget]::Machine)
String based solution is also possible if you don't want to write types
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\bin", "Machine")