Can’t set environment variables in Windows 10

Posted on

QUESTION :

I read a few answers about this. First attempt I did was by going to control panel and editing the environment variables there. However, when I move to powershell and do something like echo %MPJ_HOME%. It spits out %MPJ_HOME%

I tried restarting the terminal including the PC but it still does not work.

Then I tried running the PowerShell as Administrator and using:

setx MPJ_HOME "C:mpj-v0_44" M

It says SUCCESS: Specified value was saved..

However, again if I type echo %MPJ_HOME% again it prints %MPJ_HOME%.

I tried refreshenv as well and it still same problem.

Any ideas?

ANSWER :

I type echo %MPJ_HOME% again it prints %MPJ_HOME%

PowerShell handles environment variables differently to cmd.

To display their values in PowerShell use the following syntax:

$Env:variablename

Example:

> echo %Path%
%Path%
> $Env:Path
C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:appsWSCCSysinternals Suite;C:appsWSCCNirSoft Utilities
>

Further Reading

Leave a Reply

Your email address will not be published.