Windows 10 lets you change or add custom environment variables. Here’re the steps to add environment variable in Windows 10.
Windows has several different built-in environment variables to open folders, directories, and running processes. Some of the built-in variables include but not limited to TEMP, userprofile, windir, prefetch, etc. In fact, Windows even creates some custom environment variables for its own applications. For example, to open the OneDrive folder, you can simply execute the “OneDrive” command in the Run window. This happens because OneDrive created a new environment variable in the background.
If you have a directory or process that you want to open with a dynamic value, you can add an environment variable for that. For instance, I have a custom variable to open my downloads folder. This makes it easy to access the folder in custom scripts and other applications. I don’t have to worry about the actual folder location as long as it is properly configured in the environment variable.
In this quick and simple guide, let me show you the steps to add environment variable in Windows 10.
Steps to Add Environment Variable in Windows 10
To add a new environment variable, follow the steps listed below.
- Open the Start menu by pressing the “Windows Key”.
- Type “Environment variables” and click on the “Edit the system environment variables” result.
- Click the “Environment variables” button under the “Advanced” tab.
- You can either create a User Variable or a System Variable.
- User variable: available to only that specific user.
- System variable: available to all users including the system programs.
- To create a user variable, click “New” under the “User Variables” section.
- To create a system variable, click “New” under the “System Variables” section.
- Now, type the variable name in the first field. Make sure the name has no spaces or special characters.
- Next, type the variable value in the second field. For example, to open a folder, you have to enter its path in the Value field.
- Click “Ok” to add the environment variable.
- Click “Ok” in the environment variables window.
- In the main window, click “Apply” and “Ok” buttons.
- Restart Windows 10 to apply the new environment variable.
That is all. From now on, you can use the custom variable from the Command Prompt window or Run window. To use the environment variable, add “%” to the start and end of the variable name. For example, if I want to open the downloads folder, I need to execute the “%downloads%” command. If you don’t add the “%” sign, Windows won’t recognize the variable value.
Important Note: If you want the operating system or the command line to access an executable then you need to add it as a value to the PATH variable. For example, to access Python from the Windows command line, you need to add Python executable to the PATH variable. Creating a new custom variable will not work.
That is all. I hope that helps. If you are stuck or need some help, comment below and I will try to help as much as possible.