How to Set User Environment Variable Using Setx in Windows 10

If you’re logged in as standard user in Windows, you may not be able to set user environment variables via the user interface. This is due to a bug in Windows 10 where clicking "Change my environment variables" link in the User Accounts Control Panel doesn’t work.

Update: 3-August 2016 – The "Change my environment variables" link has been fixed in Windows 10 Anniversary Update (also known as Redstone 1) build. If you’re still using an earlier build you need to set the environment variable using Command Prompt, as mentioned below.

The following command-line is executed when you click the link, but it has no effect in Windows 10 v1511 and earlier, whether you run it as standard user or administrator.

rundll32 sysdm.cpl,EditEnvironmentVariables

Alternately, you can use the Setx command to set user environment variables.

Setting User Environment Variable

Open a Command Prompt window and type SETX /? to know the command usage. For example to set the JAVA_HOME variable, you would use:

SETX JAVA_HOME "C:\Program Files\Java\jdk1.6.0_02"

(Depending upon the version of the JDK installed, bitness of your OS, change the JDK folder path accordingly.)

This permanently sets the environment variable for your user account, and takes effect for future Command Prompt windows.

Command Prompt



Delete a User Environment Variable

To clear the user variable, use this syntax/example:

SETX JAVA_HOME ""

This however, doesn’t delete the value from the following registry key:

HKEY_CURRENT_USER\Environment

So you need another command to clear it, although this is optional.

REG DELETE HKCU\Environment /V JAVA_HOME /F

This clears the JAVA_HOME user variable.

Note: Setx can also be used to set System Environment Variables using the "/M" switch, but you need to run it from elevated or administrator Command Prompt.

About the author

Ramesh Srinivasan founded Winhelponline.com back in 2005. He is passionate about Microsoft technologies and has a vast experience in Windows — delivering support for Microsoft's consumer products. He has been a Microsoft MVP (2003-2012) who contributes to various Windows support forums.

Leave a Comment