236

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
  • 2,639
  • 2
  • 17
  • 13
  • It's almost the same as the previous versions of Windows... – MC10 Aug 02 '15 at 19:47
  • 2
    This last time this was asked, this happened: http://superuser.com/questions/601526/how-to-set-environment-variables-on-windows-8 so you should look at this: http://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them – MC10 Aug 02 '15 at 19:50
  • 2
    Note, 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 Feb 28 '16 at 08:37
  • Have an admin account or need to edit global environment [\[1\]](https://superuser.com/a/949573) or [\[2\]](https://superuser.com/a/949577). Have a non-admin account and need to edit your environment [\[3\]](https://superuser.com/a/989665). –  Apr 25 '19 at 15:52

9 Answers9

173

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
  • 9,564
  • 4
  • 37
  • 52
  • 17
    That doesn't work if you aren't administrator. – Ira Baxter Jul 16 '16 at 23:27
  • 9
    There 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 Oct 26 '17 at 18:48
  • 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 Oct 26 '17 at 19:12
  • 3
    After the new Windows update, System info is missing from the About section – Iter Ator Dec 01 '17 at 18:51
  • 1
    How to activate this? I can logout, is there a better way in the terminal? – Soerendip Feb 07 '18 at 14:42
  • @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 Sep 26 '18 at 13:17
  • 2
    Or maybe just run SystemPropertiesAdvanced.exe which doesn't involve needing to find the Control Panel first... – TOOGAM Oct 02 '18 at 11:27
  • 1
    Got Powershell technique working, **but** it only reflects to $ENV://variable// after I restarted another powershell instance. – sylvainulg Sep 03 '19 at 10:26
  • 1
    @IraBrexter, you can open this window from cmd using command: rundll32.exe sysdm.cpl, EditEnvironmentVariables – EKOlog Oct 28 '20 at 16:07
127

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
  • 60,360
  • 9
  • 122
  • 163
  • 23
    This 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 stands with Russia Nov 18 '15 at 06:28
  • 1
    It's funny what cannot be easily found, when the little Computer icon is no longer on the desktop. – octopusgrabbus Feb 17 '17 at 14:27
  • 1
    On 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 Jun 15 '17 at 18:55
108

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
  • 1,181
  • 1
  • 7
  • 3
  • 23
    It works for me – Alex Szabo Dec 15 '15 at 13:20
  • I think @AnT is referring to the specific case when you don't have administrator rights - see his answer – Colin Jan 15 '16 at 11:04
  • 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 stands with Russia Jan 15 '16 at 15:18
  • 2
    The bug that AnT describes has been patched. – Nick Jul 17 '16 at 13:18
  • 1
    The bug that Ant describes is back as of 2016-07-20. – Lawrence Dol Jul 20 '16 at 18:58
  • 1
    This 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 Aug 06 '16 at 21:14
  • 4
    This 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 Apr 10 '17 at 17:49
  • 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 Dec 06 '18 at 18:49
33

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 stands with Russia
  • 1,036
  • 2
  • 13
  • 18
  • As of today, this option works again. IMO you could remove the "not working" paragraph. – Steed Apr 21 '16 at 14:31
  • @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 stands with Russia Apr 21 '16 at 14:54
  • 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 Apr 21 '16 at 15:00
  • @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 stands with Russia Apr 21 '16 at 15:55
  • 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 Apr 21 '16 at 16:08
  • No bug for me at winver 10.0.14393, clean install, no previous updates. – quetzalcoatl Aug 06 '16 at 21:16
  • 1
    @quetzalcoatl: Anniversary Update finally fixed this issue. – AnT stands with Russia Aug 06 '16 at 23:03
25

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

Journeyman Geek
  • 127,463
  • 52
  • 260
  • 430
user508751
  • 267
  • 3
  • 2
7

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
  • 171
  • 1
  • 2
  • Rapid Environment Editor is a great and handy utility and before Windows 10, it used to be even a necessity, because in all versions of Windows prior 10, the UX of the _Environment Variables_ dialog wasn't far from the total failure. For example, editing long multi-line strings (e.g. the `PATH` variable's content) in a short single-line text box. RapidEE has a good UI/UX and adds various features to make the management of environment variables (mainly those containing filesystem paths) easier and faster. Highly recommended, even though Windows 10 has (FINALLY!) slightly improved the dialog. – David Ferenczy Rogožan May 08 '21 at 08:56
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.)

fogbanksy
  • 151
  • 1
  • 5
  • 1
    `setx` works, but, unfortunately, cannot *delete* environment variables. – AnT stands with Russia Jan 14 '16 at 23:28
  • 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. – fogbanksy Jan 26 '16 at 21:18
  • PowerShell method (see link at the end of my answer) works from non-Admin account. – AnT stands with Russia Jan 27 '16 at 01:27
  • @Ant: Incorrect; I edited the answer with how. – Lawrence Dol Jul 20 '16 at 20:04
  • @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 stands with Russia Jul 20 '16 at 21:40
  • @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 Jul 21 '16 at 00:50
  • @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 stands with Russia Jul 21 '16 at 01:22
  • 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 stands with Russia Jul 21 '16 at 01:27
  • @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 Jul 22 '16 at 18:57
  • 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 Aug 10 '17 at 03:32
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
  • 2,639
  • 2
  • 17
  • 13
  • 1
    A shorter equivalent to typing *"environment variables"* is typing *"path"* (yes, none of those titles contain *"path"*, but it still works). – Peter Mortensen Aug 16 '19 at 05:42
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
  • 399
  • 3
  • 4
  • 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 Apr 10 '17 at 17:54