Home > other >  Why do I have different values in Environment variables?
Why do I have different values in Environment variables?

Time:12-06

When I do:

[Environment]::GetEnvironmentVariable('Path') -split ';'

or

$env:path -split ';'

I get this result, which has bunch of duplicates enter image description here

but when I open the environment variables from control panel, I see this:

enter image description here

I'm using a standard account and PowerShell is running as standard too, trying to modify the current user's Path.

I tried closing and reopening PowerShell and restarting the computer, but I still see different values between control panel and PowerShell output. why is that?

p.s I previously used .NET in PowerShell to add a location to the path variable of my current standard user, and the variables weren't originally like that, I was just trying some thing with them and ended up like that, but I cleaned the duplicates in control panel, I just can't get the PowerShell to show the correct cleaned version of them. I have no idea at which point I messed it up but I need to know why I'm getting different results.

CodePudding user response:

Path environment variable returned by GetEnvironmentVariable consists of merged Path from User variables and System variables. The provided screenshot seems to show only Path from User variables, check System variables Path also (and check it for duplicate entries).

  • Related