How to set an environment variable in Windows 10
To set an environment variable in Windows 10:
- Search for “edit environment variable” in the Start menu.
- From the popup which appears, select the variable to edit and press “Edit”, or click “Create”.
- Change the name and value of the variable to your new values.
Applies to All Windows 10 Versions
Environment variables are global values used to configure programs running on your PC. Although they sound technical, they’re really just a shared configuration store for different apps to hook into.
Environment variables are tied to individual user accounts, so different users can have different configurations. There are also global system variables, such as “%windir%”, which always points to the directory where Windows is installed (e.g. “C:\Windows”). Instead of hardcoding this value, apps can instead reference “%windir%” when they need to access the Windows directory.
Many apps add their own environment variables after installation. To view and edit your environment variables, search for “edit environment variables” in the Start menu and select the result which appears.
Here, you can see all the environment variables which have been set on your machine. In the example above, you can see the “OneDrive” variable points to the OneDrive storage directory for the current user – if you change the OneDrive directory from the OneDrive system tray, this value will update accordingly.
Because OneDrive is an environment variable, programs can get the location of your OneDrive directory using “%OneDrive%” in paths. You can even try this out yourself – press Win+R to open the Run prompt and type “%OneDrive%” to open your OneDrive folder.
To edit an environment variable, select it from the list and click “Edit.” Use the popup prompt to change the variable’s name and value. However, take care when editing variables you didn’t create – an incorrect value could prevent a program, or the entire system, from running properly.
Creating a new variable is a similarly simple affair – click the “New” button and fill out the name and value. Remember though that environment variables do nothing on their own. Since no program will use your variable, it will have no effect. However, you can get the value of your environment variable using the Command Prompt – launch it from the Start menu and type “echo %<myvariable>%”, replacing “<myvariable>” with your variable’s name, to see its value displayed.