11

I am a non administrative user in windows 10 machine. I was trying to set java and gradle path for my account. As a normal user I don't have access to environment variables through control panel. In unix, I can easily change bashrc and set path for my account. In windows I tried to set the variables using setx or set command but these are not persisting for my account.I tried powershell commands also but got access denied error. So, my question is that if I am doing something wrong and if there is a way I can set the path using commands or in windows non admin users can't set path variables permanently.

setx /s machinename /u domain\username PATH "%PATH%;C:\dir1\dir2"

I looked into the other answer which worked for windows 7, but when I tried below command windows 10, nothing happens:

"C:\Windows\system32\rundll32.exe" sysdm.cpl,EditEnvironmentVariables

3 Answers3

18

Press Win+I ("eye", not "ell") to open the system settings dialog.

In the search box type "environment".

Choose "Edit Environment variables for your account".

Kevin E
  • 593
1

But.. wait, you are trying to set this User environment path on a remote machine using that ...

setx /s [machinename] 

... that could be a problem. Even with all out PSRemotig, you must be a local admin to do many things.

As for doing this on your local machine. Are you saying you tried setting the path this way as well...

[Environment]::SetEnvironmentVariable("PATH", "C:\TestPath", "User")

...and it did not stick?

Lastly, if your target is not running the Windows 10 Fall Creators Update, you cannot do this as a regular user. This was a bug pre-Win10FCU.

postanote
  • 5,136
0

There are two PATH variables (and two sets of environment variables, generally). There are those for the current user, and those for the current machine. These are combined for each user who logs in.

See here for details

jpaugh
  • 1,390