环境变量是描述应用运行环境的用户变量或Windows系统变量。(Windows)它们可以告诉您的应用程序诸如计算机名称、用户帐户名称、当前工作目录等信息。您想了解更多有关如何使用环境用户变量和Windows系统变量的信息吗?如果您这样做,请阅读本教程并了解如何在Windows 10中创建环境变量。在某些情况下,知道如何做到这一点非常有用。
注意:(NOTE:)要创建用户变量和Windows系统变量,您必须访问环境变量(Environment Variables)窗口。如果您不知道如何操作,一个快速的方法是在Run window (Win + R)“rundll32.exe sysdm.cpl,EditEnvironmentVariables”。但是,还有其他方法可以打开它,我们在本指南中介绍了这些方法:Windows 中的环境变量是什么?(What are Environment Variables in Windows?).
如何在Windows 10中创建环境用户变量(Windows 10)
用户(User)环境变量仅对您的用户帐户可用。创建此类变量时,它们的值应包括指向您的用户帐户可访问的位置的路径。例如,您不能让您的用户变量指向另一个用户帐户的个人文件夹(如Documents、Pictures、Music等)。在“[用户帐户] 的用户变量”(“User variables for [user account]”)部分,单击或点击新建(New)。
Windows 10 环境变量(Environment Variables)窗口
“新用户变量”(“New User Variable”)窗口打开。首先(Start)键入要创建的变量的名称 (1)。使其具有暗示性,以便您可以轻松记住其目的。然后,键入其值 (2)。
该值可以包括路径或更多。路径可以指向文件夹或文件。您还可以使用其他现有变量来构建您想要的路径。例如,您可以使用%Userprofile%Desktop之类的值将变量指向您的用户帐户的Desktop。如果您希望它有多个值,请用分号 ( ; ) 分隔这些值 - 例如,路径 1; 路径 2;路径 3。(Path 1; Path 2; Path 3.)
输入新用户变量的名称和值
注意:(NOTE:)不强制只使用文件夹和文件的路径作为用户变量的值。根据您要对创建的变量执行的操作,您还可以将文本字符串存储为其值。
完成用户变量设置后,单击或点击OK。新变量已添加到用户变量列表中,但尚未创建,因此此时您不能使用它。
新的用户变量已添加到列表中
对于要创建的新环境变量,在Environment Variables窗口中,单击或点击OK。
在Windows 10(Windows 10)中保存新的用户变量
要测试用户变量是否已成功创建以及它是否指向您想要的内容,请打开Run window (Windows + R)。% )之间键入您刚刚创建的环境变量的名称。例如,要执行我们刚刚创建的digitalcitizen变量,我们必须输入%digitalcitizen%。然后,我们按下OK。在我们的例子中,它打开了在我们用户的Documents中找到的(Documents)digitalcitizen文件夹。
在Windows 10(Windows 10)中检查用户变量
重要提示:(IMPORTANT:)任何用户都可以添加、更改或删除用户环境变量。用户(User)变量可以由Windows 10、应用程序和用户创建。
如何在Windows 10中创建(Windows 10)Windows系统变量
创建系统变量的过程与创建用户变量的过程相同。为了确保你做对了,让我们看另一个简单的例子。
在系统变量(System variables)部分中,单击或点击新建(New)。
开始创建新的Windows系统变量的过程
新建系统变量(New System Variable)窗口打开。输入变量的名称 (1) 及其值 (2)。请注意,您可以向一个变量添加多个值 - 您需要做的就是用分号(;)将它们分开。
输入新系统(New System)变量的名称和值
重要提示:(IMPORTANT:)如果您将路径指定为系统变量的值,则所有用户帐户都应该可以访问该路径。如果该路径指向只有一个用户帐户可以访问的位置,您应该创建一个用户变量而不是系统变量。
完成自定义新系统变量后,单击或点击OK。新变量已添加到系统变量列表中,但尚未创建。
Windows系统变量已添加到列表中
在“环境变量(Environment Variables)”窗口中,单击或点击“确定(OK)”以创建新的环境变量。
保存新的Windows系统变量
要测试用户变量是否创建成功,请打开Run (Windows + R)(%)之间插入您创建的环境系统变量的名称。例如,要运行我们创建的Games变量,我们必须输入%Games%。然后,我们按下OK。
验证 Windows 系统变量
Windows 打开了所有游戏都安装在我们的 Windows 10 测试计算机上的Games文件夹。(Games)所有用户都可以访问此文件夹,并且他们可以使用此变量快速访问这些游戏。
重要提示:(IMPORTANT:) 您(Are)是否想知道是否有任何用户可以添加系统环境变量或更改现有环境变量的值?答案是不!只有管理员可以执行这些操作。标准(Standard)用户没有足够的权限来创建或更改Windows系统变量,因为它们会影响 PC 上的每个用户和每个应用程序。本教程(This tutorial)提供有关标准和管理员(Administrator)帐户的更多详细信息。
您创建了哪些用户变量或Windows系统变量?
在Windows 10(Windows 10)中创建环境变量所涉及的过程并不复杂。但是,在您掌握它之前,您应该首先通过创建几个不会对系统运行产生负面影响的安全用户变量来进行试验。
How to create user variables and system environment variables in Windows 10 -
Environment variables are user variаbles or Windows system variables that describе the environment in which apps run. They сan tеll your apps thingѕ like the name of the computer, the name of the user аccount, the сurrent working directory, etc. Do you want tо know more аbout how to use environment uѕer variables and Windows system varіables? If you do, read this tutorial and leаrn how to creatе environment variables in Windows 10. Τhere arе sоme situations in which knowing how to do that can prove very useful.
NOTE: To create user variables and Windows system variables, you have to access the Environment Variables window. If you don’t know how to do that, a quick way to do it is by executing the command “rundll32.exe sysdm.cpl,EditEnvironmentVariables” in the Run window (Win + R). However, there are other ways to open it, which we covered in this guide: What are Environment Variables in Windows?.
How to create environment user variables in Windows 10
User environment variables are available only to your user account. When creating such variables, their values should include paths towards locations that are accessible to your user account. For example, you can’t have your user variable point to a personal folder of another user account (like Documents, Pictures, Music, etc.). In the “User variables for [user account]” section, click or tap New.
The Windows 10 Environment Variables window
The “New User Variable” window opens. Start by typing the name of the variable you want to create (1). Make it something suggestive so that you can easily remember its purpose. Then, type its value (2).
The value may include a path or more. A path can point to a folder or a file. You can also use other existing variables to build up the path you want. For example, you can use a value like %Userprofile%Desktop to point the variable to your user account’s Desktop. If you want it to have more than one value, separate the values with semicolons (;) — for example, Path 1; Path 2; Path 3.
Entering the name and value of a new user variable
NOTE: It is not mandatory to use only paths to folders and files as values for user variables. Depending on what you want to do with the variable you create, you can also store strings of text as its value.
When you are done setting the user variable, click or tap OK. The new variable is added to the list of user variables, but it is not yet created, so you can’t use it at this time.
The new user variable has been added to the list
For the new environment variable to be created, in the Environment Variables window, click or tap OK.
Saving the new user variable in Windows 10
To test if the user variable was created successfully and that it points to what you want, open a Run window (Windows + R). Type the name of the environment variable you just created, between percent (%) signs. For example, to execute the digitalcitizen variable we just created, we had to type %digitalcitizen%. Then, we pressed OK. In our case, it opened the digitalcitizen folder found in our user’s Documents.
Checking a user variable in Windows 10
IMPORTANT: Any user can add, change, or delete user environment variables. User variables can be created by Windows 10, apps, and users alike.
How to create Windows system variables in Windows 10
The process for creating system variables is the same as for creating user variables. To make sure you get it right, let’s go through another quick example.
In the System variables section, click or tap New.
Starting the process of creating a new Windows system variable
The New System Variable window opens. Enter the name of the variable (1) and its value (2). Note that you can add multiple values to a variable - all you need to do is separate them with semicolons (;).
Entering the name and value of a New System Variable
IMPORTANT: If you specify a path as a value for a system variable, that path should be accessible to all user accounts. If that path points to a location where only one user account has access, you should create a user variable instead of a system variable.
When you are done customizing the new system variable, click or tap OK. The new variable is added to the list of system variables, but it is not yet created.
The Windows system variable has been added to the list
In the Environment Variables window, click or tap OK so that the new environment variable is created.
Saving a new Windows system variable
To test if the user variable was created successfully, open Run (Windows + R) and insert the name of the environment system variable you created, between percent (%) signs. For example, to run the Games variable that we created, we had to type %Games%. Then, we pressed OK.
Verifying a Windows system variable
Windows opened the Games folder where all games are installed on our Windows 10 test computer. All users have access to this folder, and they can use this variable to access those games quickly.
IMPORTANT: Are you wondering whether any user can add system environment variables or change existing ones’ values? The answer is NO! Only administrators can perform these actions. Standard users don’t have enough clearance to make or change Windows system variables because they affect every user and every app on the PC. This tutorial provides more details about standard and Administrator accounts.
What user variables or Windows system variables did you create?
The process involved in creating environment variables in Windows 10 is not that complicated. However, before you get the hang of it, you should experiment first by making a couple of safe user variables that don’t negatively impact the system’s functioning.