Reputation: 11
I tried to do it the following way: logged in as Admin, opened cmd as admin
powershell.exe -executionpolicy bypass -command $new= ';C:\Program Files\Google\Chrome\Application'; $env:path += $new ; write-output $env:path; [System.Environment]::SetEnvironmentVariable('path',$env:path);$env:path
In this session I see the correct Path, opening a new cmd Window the old Path is unchanged.
Thanks for your help
Upvotes: 1
Views: 196
Reputation: 4372
I think you're close enough, you just need to specify Machine scope:
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Dummy", "Machine")
This doesn't affect the existing Powershell/Cmd sessions, but any new sessions created after this should report C:\Dummy
as part of their env:$Path
.
Upvotes: 1