windows 用户变量和系统变量有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4477660/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:53:58  来源:igfitidea点击:

What is the difference between user variables and system variables?

windowspathoperating-systemenvironment-variables

提问by rookie

What is the difference between user variables such as PATH, TMP, etc. and system variables?

什么是用户变量,如之间的区别PATHTMP等和系统变量?

I accidentally deleted the user variable PATH. What am I supposed to do?

我不小心删除了用户变量PATH。我应该做些什么?

采纳答案by user541686

Right-click My Computer and go to Properties->Advanced->Environmental Variables...

右键单击我的电脑,然后转到属性->高级->环境变量...

What's above are user variables, and below are system variables. The elements are combined when creating the environment for an application. System variables are shared for all users, but user variables are only for your account/profile.

上面是用户变量,下面是系统变量。在为应用程序创建环境时组合这些元素。系统变量为所有用户共享,但用户变量仅适用于您的帐户/配置文件。

If you deleted the system ones by accident, bring up the Registry Editor, then go to HKLM\ControlSet002\Control\Session Manager\Environment(assuming your current control set is notControlSet002). Then find the Pathvalue and copy the data into the Pathvalue of HKLM\CurrentControlSet\Control\Session Manager\Environment. You might need to reboot the computer. (Hopefully, these backups weren't from too long ago, and they contain the info you need.)

如果您不小心删除了系统,请打开注册表编辑器,然后转到HKLM\ControlSet002\Control\Session Manager\Environment(假设您当前的控件集不是ControlSet002)。然后找到该Path值并将数据复制到 的Path值中HKLM\CurrentControlSet\Control\Session Manager\Environment。您可能需要重新启动计算机。(希望这些备份不是很久以前的,它们包含您需要的信息。)

回答by Akshaya Aradhya

Environment variables are 'evaluated' (ie. they are attributed) in the following order:

环境变量按以下顺序“评估”(即它们被赋予属性):

  1. System variables
  2. Variables defined in autoexec.bat
  3. User variables
  1. 系统变量
  2. autoexec.bat 中定义的变量
  3. 用户变量

Every process has an environment block that contains a set of environment variables and their values. There are two types of environment variables: user environment variables (set for each user) and system environment variables (set for everyone). A child process inherits the environment variables of its parent process by default.

每个进程都有一个环境块,其中包含一组环境变量及其值。有两种环境变量:用户环境变量(为每个用户设置)和系统环境变量(为每个人设置)。子进程默认继承其父进程的环境变量。

Programs started by the command processor inherit the command processor's environment variables.

命令处理器启动的程序继承命令处理器的环境变量。

Environment variables specify search paths for files, directories for temporary files, application-specific options, and other similar information. The system maintains an environment block for each user and one for the computer. The system environment block represents environment variables for all users of the particular computer. A user's environment block represents the environment variables the system maintains for that particular user, including the set of system environment variables.

环境变量指定文件的搜索路径、临时文件的目录、特定于应用程序的选项和其他类似信息。系统为每个用户维护一个环境块,为计算机维护一个环境块。系统环境块代表特定计算机的所有用户的环境变量。用户的环境块表示系统为该特定用户维护的环境变量,包括系统环境变量集。

回答by Darin Dimitrov

System environment variablesare globally accessed by all users.
User environment variablesare specific only to the currently logged-in user.

所有用户都可以全局访问系统环境变量
用户环境变量仅特定于当前登录的用户。

回答by Alesper3

Just recreate the Path variable in users. Go to user variables, highlight path, then new, the type in value. Look on another computer with same version windows. Usually it is in windows 10: Path %USERPROFILE%\AppData\Local\Microsoft\WindowsApps;

只需在用户中重新创建 Path 变量。转到用户变量,突出显示路径,然后新建,输入值。在具有相同版本 Windows 的另一台计算机上查看。通常它在 Windows 10 中:路径 %USERPROFILE%\AppData\Local\Microsoft\WindowsApps;

回答by Anusree

Environment variable (can access anywhere/ dynamic object) is a type of variable. They are of 2 types system environment variables and user environment variables.

环境变量(可以在任何地方访问/动态对象)是一种变量。它们有两种类型的系统环境变量和用户环境变量。

System variables having a predefined type and structure. That are used for system function. Values that produced by the system are stored in the system variable. They generally indicated by using capital letters Example: HOME,PATH,USER

具有预定义类型和结构的系统变量。用于系统功能。系统产生的值存储在系统变量中。它们一般用大写字母表示 例如:HOME,PATH,USER

User environment variables are the variables that determined by the user,and are represented by using small letters.

用户环境变量是由用户决定的变量,用小写字母表示。