How do I set system environment variables in Windows 10?

209

53

How do I set a system environment variable in Windows 10 (without using the registry editor)?

(Note: Other answers don't specifically address Windows 10 - at least not yet - and they leave off important steps - like how to open the control panel - that changed since previous versions of Windows.)

Jared

Posted 2015-08-02T19:45:55.167

Reputation: 2 361

Question was closed 2016-03-13T14:55:09.300

It's almost the same as the previous versions of Windows... – MC10 – 2015-08-02T19:47:12.027

2Note, none of the answers work if you're not running an admin account and want to add an environment variable to that non-admin account. – casperOne – 2016-02-28T08:37:04.550

Have an admin account or need to edit global environment [1] or [2]. Have a non-admin account and need to edit your environment [3].

– Camila Hunter – 2019-04-25T15:52:53.590

Answers

151

Update: After seeing lots of comments about setting environment variables without admin in Windows 10, I think I have found a way. I was not admin and could use PowerShell.

PowerShell method

You can list all environment variables with: Get-ChildItem Env:.

To get the value of a specific variable: $Env:PATH, where PATH is the name of the variable.

To set a variable: [Environment]::SetEnvironmentVariable("PATH", "C:\TestPath", "User"), the first parameter is the name of the variable, the second is the value, the third is the level of.

There are different ways to work with environment variables and certain quirks with them in PowerShell so consult the link for details.

Old method (no longer available in newer Windows 10 updates, use PowerShell or see other answers)

Go into Settings and click on System.

System

Then on the left side click About and select System info at the bottom.

About

In the new Control Panel window that opens, click Advanced system settings on the left.

Advanced system settings

Now in the new window that comes up, select Environment Variables... at the bottom.

Environment Variables

MC10

Posted 2015-08-02T19:45:55.167

Reputation: 7 590

15That doesn't work if you aren't administrator. – Ira Baxter – 2016-07-16T23:27:31.727

4There is a direct path in a more recent Windows 10: in the main Settings window, just type "Path" into the search box and options to jump straight to the variable editors will appear. Saves a few steps of clicking. – jakobengblom2 – 2017-10-26T18:48:57.023

Updated answer with a PowerShell method which should work when not an admin. I'm not 100% sure on the admin part as I am on a company laptop, and I am usually prompted for admin actions and but I was not for PowerShell and this worked. – MC10 – 2017-10-26T19:12:56.930

3After the new Windows update, System info is missing from the About section – Iter Ator – 2017-12-01T18:51:29.260

1How to activate this? I can logout, is there a better way in the terminal? – Sören – 2018-02-07T14:42:25.003

@Iter Ator: You can still access it by searching for "system info". Clicking on the System app (the app of the second last image of this answer will open), you can access the advanced settings (works on newer windows 10 updates). – 1stthomas – 2018-09-26T13:17:04.123

1Or maybe just run SystemPropertiesAdvanced.exe which doesn't involve needing to find the Control Panel first... – TOOGAM – 2018-10-02T11:27:44.770

Got Powershell technique working, but it only reflects to $ENV://variable// after I restarted another powershell instance. – sylvainulg – 2019-09-03T10:26:21.427

120

Still the same as ever: It’s in the old-style control panel’s “System” thingy. You can reach it with WinBreak or by right-clicking the Start button.

From there, select “Advanced system settings” → “Environment Variables”.

Or you can do it the hard way and find some other entry point to the old-style control panel, like the Network and Sharing Center or the Desktop folder(!).

Daniel B

Posted 2015-08-02T19:45:55.167

Reputation: 40 502

21This method is only applicable to accounts from Administrators group. It is not possible to change environment variables of a regular User level account using this method. – AnT – 2015-11-18T06:28:23.267

1It's funny what cannot be easily found, when the little Computer icon is no longer on the desktop. – octopusgrabbus – 2017-02-17T14:27:17.200

1On my system, the PATH environment variable allows editing, but PowerShell truncates the value after 2542 characters. However, it appears to retain the entire list of paths internally, so even though you can't see the entire list of paths from the prompt, it uses the entire list to find commands. – Suncat2000 – 2017-06-15T18:55:28.167

89

I typed "envir" in the "Search the web and Windows" box and selected "Edit environment variables for your account" under the "Best Match"

enter image description here

Colin

Posted 2015-08-02T19:45:55.167

Reputation: 991

1Unfortunately, doing this search no longer produces such search result. – AnT – 2015-11-18T07:57:38.493

22It works for me – Alex Szabó – 2015-12-15T13:20:48.630

I think @AnT is referring to the specific case when you don't have administrator rights - see his answer – Colin – 2016-01-15T11:04:01.997

6@Alex Szabó: I was wrong when I said "no longer produces such result". The serach result are indeed the same. But clicking of the first result (highlighted in your picture) in current Windows 10 does nothing for non-admin accounts. It is a "dead link". This is the same bug, introduced by 1511 update as the one described in my answer. So no, it doesn't really work in general case. – AnT – 2016-01-15T15:18:20.430

2The bug that AnT describes has been patched. – Nick – 2016-07-17T13:18:07.413

1The bug that Ant describes is back as of 2016-07-20. – Lawrence Dol – 2016-07-20T18:58:49.020

1This is the correct answer for Win10. Answers from Daniel and MC10 will modify only system variables or variables for administrator account. As for the bug, I have a fresh install of Win10 with latest patches/upgrades as of this date (2016-08-06, winver 10.0.14393) and searching for "variable" in menu start produced correct 2 hits (edit-vars-for-system and edit-vars-for-this-account). "system" version requires admin rights. "account" version does not require them and works correctly. – quetzalcoatl – 2016-08-06T21:14:19.007

4This is the answer. If you are using another language, you must type the equivalence in that language (in my case Chinese/Spanish). Type "variable del sistema" when you set Spanish as your preferred language, or “系统变量” when you use Chinese. It's there. You cannot miss it.BTW, it applies to all the searching work in this searching bar, and when you cannot find the Control Panel, you can type "control panel"/ "panel de control"/“控制面板” there. It's well designed. – WesternGun – 2017-04-10T17:49:09.873

Best answer, actually works! – Ken Syme – 2017-11-16T09:33:41.080

This works on build 1709. Specific solutions should indicate the build they were successful on as Microsoft changes things quite a bit between builds. – Dacid Salin – 2018-12-06T18:49:41.057

29

If by "system environment variables" you refer specifically to system-wide environment variables, then other answers have already covered this. However, if you want to edit both system-wide and user-specific environment variables then most (if not all) of these answers are inapplicable in general case.

Going through "System" and then “Advanced system settings” -> “Environment Variables” will only work for accounts from Administrators group, because only such accounts have access to “Advanced system settings”.

If you attempt do that from a regular user account, then trying to access “Advanced system settings” will trigger an UAC prompt asking you for administrator password. If you enter the password, “Advanced system settings” will successfully open, but any user-specific changes you make there will apply to the corresponding administrator's account (!), not to your original user's account.

In order to solve this problem (i.e. in order to give regular users the opportunity to edit their own environment variables) Windows provides another way to access the “Environment Variables” dialog.

Open Control Panel. Open User Accounts applet. On the left-hand side of that applet you will see a link that says Change my environment variables. Click that link, and it will take you to the same “Environment Variables” dialog for your user's environment variables.

enter image description here

If your user has administrator rights, you will be able to edit both sections of that dialog: user-specific environment variables (upper section) and system-wide environment variables (lower section). If you don't have administrator rights, you will only be able to edit the upper section: your own user-specific environment variables.

This is the proper way to edit environment variables in all post-UAC versions of Windows, not what is suggested in the majority of the answers above.


Unfortunately, Windows 10 November update (version 1511) destroyed this functionality. The Change my environment variables link no longer works. It is there, but it is dead. So for the post-November version of Windows 10 the correct answer is: it is generally impossible to edit user-specific environment variables in version 1511 of Windows 10 from regular user accounts. Microsoft has destroyed Windows 10 with this update and Windows 10 is now unusable. It will remain the case until they fix these ridiculous bugs in 1511 version of the OS.

For the time being one workaround for non-administrative accounts is to, well, add your user account to Administrators group, logout, log back in, edit the variables using "System" -> “Advanced system settings” method, and then take away administrative rights again...

An alternative workaround is to use PowerShell features as described here https://technet.microsoft.com/en-us/library/ff730964.aspx


Windows 10 Anniversary Update (version 1607) released August 2, 2016 finally fixed this bug.

AnT

Posted 2015-08-02T19:45:55.167

Reputation: 876

As of today, this option works again. IMO you could remove the "not working" paragraph. – Steed – 2016-04-21T14:31:25.710

@Steed: My Windows 10 Pro x64 is currently "Version 1511 Build 10586.218" and that option is still dead. What build do you have? – AnT – 2016-04-21T14:54:55.803

Oh, sorry, my version is 10.0.10240 (Win 10 Pro x64), which should be older than yours. However, it's an up-to-date stock version with no updates pending in Windows Update. Maybe your one is Insider Preview or something? – Steed – 2016-04-21T15:00:13.690

@Steed: No, mine is ordinary current public version of Windows 10 Pro. Meanwhile, your version number indicates that you are running the original Windows 10. You never installed update 1511 (aka "November update", aka "Threshold 2 update"). This is why you don't have this issue, since this issue, as I said in my answer above, was introduced by 1511 update specifically. If you update your Windows to the current version, you will observe the same problem. I don't know though why Windows Update is telling you that your version is up-to-date. – AnT – 2016-04-21T15:55:43.310

Seems that it's not showing because I've upgraded to Win10 only recently, see http://windows.microsoft.com/en-us/windows-10/windows-update-faq. Now it's all clear. Sorry for making this chat under your post.

– Steed – 2016-04-21T16:08:32.453

No bug for me at winver 10.0.14393, clean install, no previous updates. – quetzalcoatl – 2016-08-06T21:16:56.770

1@quetzalcoatl: Anniversary Update finally fixed this issue. – AnT – 2016-08-06T23:03:12.160

21

Just hit Windows Key+R) at the same time to get command prompt. Then type sysdm.cpl, go to advanced and select Environmental Variables

enter image description here

user508751

Posted 2015-08-02T19:45:55.167

Reputation: 227

4This only changes environment variables for an admin. – Lawrence Dol – 2016-07-20T18:57:47.940

This is most straight forward answer which will bring you right to set up window. – jdhao – 2018-02-07T13:35:50.840

Thanks man. I am admin but I cannot change the admin variables. Now I can!!! – Guilherme – 2019-05-01T16:50:51.793

5

If you are not afraid of the command line, you should check out the command setx.

I quote from its description:

Creates or modifies environment variables in the user or system environment. Can set variables based on arguments, regkeys or file input.

(Note that this command does not affect the current command shell's environment, only the environment of new processes, so you'll need to open a new command shell to see any changes.)

fogbank

Posted 2015-08-02T19:45:55.167

Reputation: 151

1setx works, but, unfortunately, cannot delete environment variables. – AnT – 2016-01-14T23:28:51.173

True, and I don't know how to do that, other than setting the variable to an empty value, which isn't really deleting it. On the other hand, it works from a regular account (i.e.: not in the Administrators group). If I haven't missed it, none of the answers provided so far work from a non-admin account. – fogbank – 2016-01-26T21:18:39.563

PowerShell method (see link at the end of my answer) works from non-Admin account. – AnT – 2016-01-27T01:27:42.633

@Ant: Incorrect; I edited the answer with how. – Lawrence Dol – 2016-07-20T20:04:36.593

@Lawrence Dol: Er... No. Setting an env variable to blank value and deleting an env variable are two completely different things (as @fogbank already noted above). One more time: setx does not support deletion of variables. – AnT – 2016-07-20T21:40:21.210

@Ant: Er... Setting a variable to blank using SETX deletes the variable. One more time, I did it, and it does, in Windows 10. Using exactly the command line I edited into the answer. Why the snarky response? – Lawrence Dol – 2016-07-21T00:50:07.977

@Lawrence Dol: I don't know how you managed to achieve something like that. I use Windows 10 Pro x64, latest build. If I do SETX DDD 123 and check "Environment Variables" dialog, it will show variable DDD with the value of 123 in the "User variables" section. If I follow that with SETX DDD "", the variable DDD will remain in the "User variables" section with empty value. By "deleting" a variable I mean complete removal of that variable from "User variables" in "Environment Variables" dialog. SETX does not do that for me. – AnT – 2016-07-21T01:22:08.767

If you are using set command to display the current environment, you have to keep in mind that it hides existing variables with empty values. That does not mean that the variable has been physically deleted. In Windows shell language empty variables are often equivelent to non-existent variables, which often makes it difficult to tell them apart. – AnT – 2016-07-21T01:27:15.483

@AnT: Yes, I was opening a new command shell and using set to list the variables. I did not know that it would hide blank variables. That is a dumb decision... but then, this is the Windows command shell. (Since I am affected by the bug which prevents non-admins from even displaying their environment variables, I can't even open the user dialog.) – Lawrence Dol – 2016-07-22T18:57:34.807

To delete a Env Var, follow https://stackoverflow.com/a/18899441/1586498. Note that SETX leaves a value in the registry. Try checking user registry with: reg query HKCU\Environment

– OzBob – 2017-08-10T03:32:21.953

5

I also experience the problem described by many users in this thread, i.e. the link to the dialogue to set the environment variables of non-admin users is dead. As a simple workaround I have downloaded this nice tool:

http://www.rapidee.com/en/download

It is portable and requires no permissions to install, it is simple to use, and actually provides a better overview of the variables than the system dialogue anyway.

Hope this helps.

krcools

Posted 2015-08-02T19:45:55.167

Reputation: 151

4

I found at least one way:

In the "Search the web and Windows" box on the taskbar, type "environment variables" then select "Edit the system environment variables" then click "Environment variables"

Jared

Posted 2015-08-02T19:45:55.167

Reputation: 2 361

A shorter equivalent to typing "environment variables" is typing "path" (yes, none of those titles contain "path", but it still works). – Peter Mortensen – 2019-08-16T05:42:57.410

2

In windows 10, changing the environment variables has not changed, It is the same as in windows 7: Right click on This PC (My Computer). Left Click Properties. Left Click Advanced system settings. Left Click Environment Variables...

At this point you can change the variables for the current user or the system

Rob Moore

Posted 2015-08-02T19:45:55.167

Reputation: 349

This is correct. "This PC" is under your File Explorer's left quick toolbar, it's not hidden, just needs patience to find it. That's why someone downvoted it and I see it not proper, thus the upvote from me. – WesternGun – 2017-04-10T17:54:38.300