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

migrated from serverfault.com Feb 5 '18 at 15:24

This question came from our site for system and network administrators.


Press Win+I to open the system settings dialog. In the search box type "environment" Choose "Edit Environment variables for your account"

  • Yes, the question's claim that "As a normal user I don't have access to environment variables through control panel." reflects ignorance, not lack of access. – Ben Voigt Feb 20 '18 at 4:00

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.

  • Thanks, let me try the setx without machine name. I already tried powershell command you mentioned. This is the best answer so far and my vote for you. – Pinaki Mukherjee Feb 6 '18 at 16:15

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

  • Thanks for your answer. But the answer didn't work in my windows 10. I have provided the command I used. – Pinaki Mukherjee Feb 5 '18 at 15:42

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.