Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an environment variable set via "system properties -> advanced -> Environment Variables". I modified the variable's value. In cmd, I see the new value. In PowerShell, the value is still the old value. Trying to set it with [Environment]::SetEnvironmentVariable doesn't have any effect.

share|improve this question
up vote 4 down vote accepted

PowerShell will cache its information. Use the Refresh method to solve your problem. I found this in the SQL area too.

share|improve this answer
How exactly do I run this method? – IttayD Jan 17 '10 at 19:43
On a normal directory, you should be able to do: (get-item .).Refresh() - but that doesn't seem to be available for the Env: folder. Starting a new instance of PowerShell will demonstrate that it's a caching issue - I'm just not sure right now where the Refresh method should live for it. I can query an environment variable called blah using Get-WmiObject Win32_Environment | where-object -filter {$_.Name -eq 'blah'} | select VariableValue, and this happily shows me the latest version, even though the cache still hasn't been refreshed for the env: drive. I'll look some more... – Rob Farley Jan 18 '10 at 0:46

Did you launch a new instance of PowerShell?

Every process gets its own environment block when it starts. Typically it gets a copy of the parent process environment block, but CreateProcess can also take a custom one.

This means that changes to the system environment won't affect running processes. So you'll need to start a new one.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .