Home  >  Article  >  A guide to using Windows 11 and 10 environment variables for profiling

A guide to using Windows 11 and 10 environment variables for profiling

王林
王林forward
2023-11-01 20:13:011208browse

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.

How to use profiles in environment variables Windows 11 and 10

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:

Step 1: Install PowerToys

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.

使用Windows 11和10环境变量进行配置文件操作指南

Search for PowerToys.

使用Windows 11和10环境变量进行配置文件操作指南

Click "Install".

使用Windows 11和10环境变量进行配置文件操作指南

You can also install PowerToys from its GitHub page as follows:

Click the download link on the GitHub page.

使用Windows 11和10环境变量进行配置文件操作指南

After downloading, run the PowerToys installer.

使用Windows 11和10环境变量进行配置文件操作指南

Agree to the terms and conditions and click Install.

使用Windows 11和10环境变量进行配置文件操作指南

Step 2: Enable environment variables in PowerToys

Launch PowerToys and click "Environment Variables" on the left .

使用Windows 11和10环境变量进行配置文件操作指南

On the right, open Enable environment variables.

使用Windows 11和10环境变量进行配置文件操作指南

Also, make sure to turn on "Start as Administrator" so you can make changes to the System variables if needed.

使用Windows 11和10环境变量进行配置文件操作指南

Step 3: Set up a new configuration file

Click"Start Environment Variables" to open it.

使用Windows 11和10环境变量进行配置文件操作指南

In the Environment Variables window you will find two default variable profiles on the left - User and System.

使用Windows 11和10环境变量进行配置文件操作指南

The applied variables will be on the right.

使用Windows 11和10环境变量进行配置文件操作指南

To add a new profile, click the New Profile option in the upper left corner.

使用Windows 11和10环境变量进行配置文件操作指南

and give your profile a name.

使用Windows 11和10环境变量进行配置文件操作指南

Step 4: Add Variables – New and Existing Variables

Click "Add Variable" to do this .

使用Windows 11和10环境变量进行配置文件操作指南

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.

使用Windows 11和10环境变量进行配置文件操作指南

Then click Add at the bottom.

使用Windows 11和10环境变量进行配置文件操作指南

Your new environment variables will be added to your configuration file.

使用Windows 11和10环境变量进行配置文件操作指南

To add an existing variable, click the Existing tab.

使用Windows 11和10环境变量进行配置文件操作指南

Then select the variable you want to add.

使用Windows 11和10环境变量进行配置文件操作指南

Then click Add at the bottom.

使用Windows 11和10环境变量进行配置文件操作指南

Finally, click Save.

使用Windows 11和10环境变量进行配置文件操作指南

Step 5: Edit or Delete Variables

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.

使用Windows 11和10环境变量进行配置文件操作指南

#To edit or delete a variable in the configuration file, click the three-dot icon next to the variable.

使用Windows 11和10环境变量进行配置文件操作指南

Select "Edit" to modify its name or value.

使用Windows 11和10环境变量进行配置文件操作指南

Make the necessary changes and click Save.

使用Windows 11和10环境变量进行配置文件操作指南

Select "Remove" to remove the variable from the configuration file.

使用Windows 11和10环境变量进行配置文件操作指南

Click "is" to confirm.

使用Windows 11和10环境变量进行配置文件操作指南

To edit the profile itself, click the three-dot icon next to the profile and select Edit.

使用Windows 11和10环境变量进行配置文件操作指南

This will take you to the same window as before, where you can add (and edit) new and existing variables.

使用Windows 11和10环境变量进行配置文件操作指南

To delete the profile, select "Delete".

使用Windows 11和10环境变量进行配置文件操作指南

Select "is" to confirm.

使用Windows 11和10环境变量进行配置文件操作指南

Step 6: Enable or disable the configuration file

Finally, don’t forget to open the configuration file to apply the variable set that has been added to it.

使用Windows 11和10环境变量进行配置文件操作指南

The applied variables will appear on the right side of the Environment Variables window.

使用Windows 11和10环境变量进行配置文件操作指南

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.

使用Windows 11和10环境变量进行配置文件操作指南

What happens when creating a configuration file in environment variables?

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.

Why use configuration files in environment variables

By using a separate configuration file for environment variables, you can do the following:

  • Easily add what you need new variables without changing user and system variables.
  • Manage a group of variables at a time.
  • Highlight variables with the same name as user variables.

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.

FAQ

Let's look at some frequently asked questions about using profiles with environment variables on Windows.

How to use PowerToys to modify default system variables?

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.

Which variable has priority between configuration files and user variables with the same name?

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.

Can you use two configuration files? What happens when I create multiple profiles?

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!

Statement:
This article is reproduced at:yundongfang.com. If there is any infringement, please contact admin@php.cn delete