codewario's helpful answer explains the problem and shows you how to modify the $env:PATH
variable in-session by manually appending a new directory path.
While that is a pragmatic solution, it requires that you know the specific directory path of the recently installed program.
If you don't - or you just want a generic solution that doesn't require you to hard-code paths - you can refresh the value of $env:PATH
(the PATH
environment variable) from the registry, via the [Environment]::GetEnvironmentVariable()
.NET API method:
$env:PATH = [Environment]::GetEnvironmentVariable('Path', 'Machine'),
[Environment]::GetEnvironmentVariable('Path', 'User') -join ';'
This updates $env:PATH
in-session to the same value that future sessions will see.
Note how the machine-level value (list of directories) takes precedence over the user-level one, due to coming first in the composite value.
Note:
If you happen to have made in-session-only $env:PATH
modifications before calling the above, these modifications are lost.
If applicable, this includes modifications made by your $PROFILE
file.
Hypothetically, other processes could have made additional modifications to the persistent Path
variable definitions as well since your session started, which the call above will pick up too (as will future sessions).