Environment variables are the location paths (or environments) where applications and programs are run. They can be created, edited, managed or deleted by the user and come in handy when managing the behavior of certain processes.
Here's how to create a configuration file to manage multiple variables simultaneously without having to edit them individually on Windows.
On Windows, there are two sets of environment variables – user variables (apply to the current user) and system variables (apply globally). However, using a tool like PowerToys, you can create a separate configuration file to add new and existing variables and manage them all at once. Here's how:
PowerToys has an environment variable tool that can be used to create configuration files to manage environment variables. To use it, you first need to install PowerToys. To do this, open the Microsoft Store.
Search for PowerToys.
Click "Install".
You can also install PowerToys from its GitHub page as follows:
Click the download link on the GitHub page.
After downloading, run the PowerToys installer.
Agree to the terms and conditions and click Install.
Launch PowerToys and click "Environment Variables" on the left .
On the right, open Enable environment variables.
Also, make sure to turn on "Start as Administrator" so you can make changes to the System variables if needed.
Click"Start Environment Variables" to open it.
In the Environment Variables window you will find two default variable profiles on the left - User and System.
The applied variables will be on the right.
To add a new profile, click the New Profile option in the upper left corner.
and give your profile a name.
Click "Add Variable" to do this .
Here you can add new and existing variables in the configuration file. To add a new configuration file, enter the name and value of the environment variable under New.
Then click Add at the bottom.
Your new environment variables will be added to your configuration file.
To add an existing variable, click the Existing tab.
Then select the variable you want to add.
Then click Add at the bottom.
Finally, click Save.
Your custom environment variable profile will be listed under the Profiles section. Click the down arrow next to it to view the variables that belong to the profile.
#To edit or delete a variable in the configuration file, click the three-dot icon next to the variable.
Select "Edit" to modify its name or value.
Make the necessary changes and click Save.
Select "Remove" to remove the variable from the configuration file.
Click "is" to confirm.
To edit the profile itself, click the three-dot icon next to the profile and select Edit.
This will take you to the same window as before, where you can add (and edit) new and existing variables.
To delete the profile, select "Delete".
Select "is" to confirm.
Finally, don’t forget to open the configuration file to apply the variable set that has been added to it.
The applied variables will appear on the right side of the Environment Variables window.
Please note that you can only apply one profile at a time, regardless of the number of profiles you create.
To disable a profile, simply close it.
Then, the variables you add to that configuration file will take over user and system variables when they are common. You will be able to easily turn variables on and off by opening or closing the configuration file respectively. It won't change what's in the user and system environment variables, but if those three variables were common, the order of precedence would be like this: Profile > User > System.
By using a separate configuration file for environment variables, you can do the following:
PowerToys' Environment Variables tool also allows you to manage existing user and system variables from the Default Variables section. Just make sure you run the tool as an administrator to allow changes to system variables.
Let's look at some frequently asked questions about using profiles with environment variables on Windows.
To modify the default system variables, run the Environment Variables tool in PowerToys as an administrator. Then click the System tab under Default Variables, click the three-dot icon next to the variable you want to modify, and select Edit or Delete.
If two variables have the same name, the variable belonging to the configuration file will get priority. The order of precedence of public variables is as follows: Profile>User>System.
Well, you can only use one profile at a time. You can create multiple profiles, but only one can remain active at a time.
The above is the detailed content of A guide to using Windows 11 and 10 environment variables for profiling. For more information, please follow other related articles on the PHP Chinese website!