大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
Windows 10 环境变量 (用户变量与系统变量)
Windows 10 环境变量 (用户变量与系统变量)
1. 环境变量 (environment variables)
环境变量 (environment variables) 是在操作系统中用来指定操作系统运行环境的一些参数。环境变量是在操作系统中一个具有特定名字的对象,它包含了一个或者多个应用程序所将使用到的信息。Windows 和 DOS 操作系统中的 path
环境变量,当要求系统运行一个程序而没有告诉它程序所在的完整路径时,系统除了在当前目录下面寻找此程序外,还应到 path
中指定的路径去找。用户通过设置环境变量,来更好的运行进程。
Environment variables:环境变量
User variables:用户变量
System variables:系统变量
环境变量可分为用户变量与系统变量两类,在注册表中都有对应的项。
1.1 用户变量
- 用户变量所在位置:
HKEY_CURRENT_USER\Environment
1.2 系统变量
- 系统变量所在位置:
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment
在原有变量的基础上添加英文状态下的分号,然后添加路径名。不要删除原先的系统变量,只要用分号隔开,然后添加路径名,最后也要加上分号。
1.3 echo %path%
Microsoft Windows [版本 10.0.17763.1158]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\Users\cheng>echo %path%
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\Program Files (x86)\Windows Kits.1\Windows Performance Toolkit\;C:\Users\cheng\AppData\Local\Microsoft\WindowsApps;
C:\Users\cheng>
C:\Users\cheng>echo %PATH%
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\Program Files (x86)\Windows Kits.1\Windows Performance Toolkit\;C:\Users\cheng\AppData\Local\Microsoft\WindowsApps;
C:\Users\cheng>
环境变量可以理解为系统的视线范围,配置进入了环境变量的可执行程序,就等于是进入了系统的视线范围。
- 系统变量针对所有用户起作用,为了安全一般配置用户环境变量。
- 用户变量只对当前用户起作用,不建议为了省事而配置系统环境变量。
- 环境变量不区分大小写,
path / PATH / Path
表示指定可执行文件的搜索路径。 echo %path%
用户变量会跟在系统变量的后面。- 用户环境变量优先级高于系统环境变量。对于环境变量,系统会先检查用户变量,之后再检查系统变量。
- 添加路径以后,要保存,再重启
cmd
,确保生效。 - Windows 系统在执行用户命令时,若用户未给出文件的绝对路径,则首先在当前目录下寻找相应的可执行文件。然后在用户变量的
path / PATH / Path
路径中查找,如果找不到,再到系统变量的 PATH 路径中查找。如果系统变量和用户变量的path / PATH / Path
中同时包含相同的路径,则优先使用用户变量path / PATH / Path
中的路径。
2. Setting the path and variables in Windows 10
- From the desktop, right-click the Computer icon and select Properties. If you don’t have a Computer icon on your desktop, click Start, right-click the Computer option in the Start menu, and select Properties.
- Click the Advanced System Settings link in the left column.
- In the System Properties window, click on the Advanced tab, then click the Environment Variables button near the bottom of that tab.
- In the Environment Variables window, highlight the Path variable in the System variables section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon, as shown below.
You can edit other environment variables by highlighting the variable in the System variables section and clicking Edit. If you need to create a new environment variable, click New and enter the variable name and variable value.
此电脑 -> 高级系统设置
环境变量
3. List of environment variables in Windows 10
Microsoft Windows [版本 10.0.17763.1158]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\Users\cheng>echo %COMMONPROGRAMFILES%
C:\Program Files\Common Files
C:\Users\cheng>
C:\Users\cheng>echo %COMMONPROGRAMFILES(x86)%
C:\Program Files (x86)\Common Files
C:\Users\cheng>
C:\Users\cheng>echo %COMSPEC%
C:\Windows\system32\cmd.exe
C:\Users\cheng>
C:\Users\cheng>echo %HOMEDRIVE%
C:
C:\Users\cheng>
C:\Users\cheng>echo %HOMEPATH%
\Users\cheng
C:\Users\cheng>
C:\Users\cheng>echo %SYSTEMROOT%
C:\Windows
C:\Users\cheng>echo %WINDIR%
C:\Windows
C:\Users\cheng>
C:\Users\cheng>echo %TMP%
C:\Users\cheng\AppData\Local\Temp
C:\Users\cheng>
C:\Users\cheng>echo %TEMP%
C:\Users\cheng\AppData\Local\Temp
C:\Users\cheng>
%COMMONPROGRAMFILES%
– C:\Program Files\Common Files
%COMMONPROGRAMFILES(x86)%
– C:\Program Files (x86)\Common Files
%COMSPEC%
– C:\Windows\System32\cmd.exe
%HOMEDRIVE%
– C:
%HOMEPATH%
– C:\Users\<username>
%SYSTEMROOT%
– C:\Windows
%WINDIR%
– C:\Windows
%TMP%
– C:\Users\<username>\AppData\Local\Temp
%TEMP%
– C:\Users\<username>\AppData\Local\Temp
Microsoft Windows [版本 10.0.17763.1158]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\Users\cheng>echo %APPDATA%
C:\Users\cheng\AppData\Roaming
C:\Users\cheng>
C:\Users\cheng>echo %ALLUSERSPROFILE%
C:\ProgramData
C:\Users\cheng>
C:\Users\cheng>echo %CD%
C:\Users\cheng
C:\Users\cheng>
C:\Users\cheng>echo %CMDEXTVERSION%
2
C:\Users\cheng>
C:\Users\cheng>echo %DATE%
2020/05/04 周一
C:\Users\cheng>
C:\Users\cheng>echo %ERRORLEVEL%
0
C:\Users\cheng>
C:\Users\cheng>echo %LOCALAPPDATA%
C:\Users\cheng\AppData\Local
C:\Users\cheng>
C:\Users\cheng>echo %LOGONSERVER%
\\YONGQIANG
C:\Users\cheng>
C:\Users\cheng>echo %PATH%
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\Program Files (x86)\Windows Kits.1\Windows Performance Toolkit\;C:\Users\cheng\AppData\Local\Microsoft\WindowsApps;C:\Program Files\NVIDIA Corporation\NVSMI;
C:\Users\cheng>
%APPDATA%
– C:\Users\<username>\AppData\Roaming
%ALLUSERSPROFILE%
– C:\ProgramData
%CD%
– Typing in this command will give you the current directory you are working in.
%CMDEXTVERSION%
– This variable expands to the version of the command-line extensions.
%DATE%
– This variable will give you the current date according to date format preferences.
%ERRORLEVEL%
– Determines the error level set by last executing command.
%LOCALAPPDATA%
– C:\Users\<username>\AppData\Local
%LOGONSERVER%
– \\<domain_logon_server>
%PATH%
– C:\Windows\system32;C:\Windows;
Microsoft Windows [版本 10.0.17763.1158]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\Users\cheng>echo %PATHEXT%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
C:\Users\cheng>
C:\Users\cheng>echo %PROGRAMDATA%
C:\ProgramData
C:\Users\cheng>
C:\Users\cheng>echo %PROGRAMFILES%
C:\Program Files
C:\Users\cheng>
C:\Users\cheng>echo %PROGRAMW6432%
C:\Program Files
C:\Users\cheng>
C:\Users\cheng>echo %PROGRAMFILES(X86)%
C:\Program Files (x86)
C:\Users\cheng>
C:\Users\cheng>echo %PROMPT%
$P$G
C:\Users\cheng>
C:\Users\cheng>echo %SYSTEMDRIVE%
C:
C:\Users\cheng>
C:\Users\cheng>echo %TIME%
12:34:57.39
C:\Users\cheng>
C:\Users\cheng>echo %USERNAME%
cheng
C:\Users\cheng>
%PATHEXT%
– .com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.msc
%PROGRAMDATA%
– C:\ProgramData
%PROGRAMFILES%
– C:\Program Files
%PROGRAMW6432%
– C:\Program Files
%PROGRAMFILES(X86)%
– C:\Program Files (x86)
%PROMPT%
– $P$G
%SYSTEMDRIVE%
– C:
%TIME%
– Similarly, it gives you current time according to the time format preferences.
%USERNAME%
– <username>
Microsoft Windows [版本 10.0.17763.1158]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\Users\cheng>echo %USERPROFILE%
C:\Users\cheng
C:\Users\cheng>
C:\Users\cheng>echo %USERDOMAIN%
YONGQIANG
C:\Users\cheng>
C:\Users\cheng>echo %USERDOMAIN_ROAMINGPROFILE%
YONGQIANG
C:\Users\cheng>
C:\Users\cheng>echo %PUBLIC%
C:\Users\Public
C:\Users\cheng>
C:\Users\cheng>echo %PSMODULEPATH%
C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
C:\Users\cheng>
C:\Users\cheng>echo %ONEDRIVE%
C:\Users\cheng\OneDrive
C:\Users\cheng>
C:\Users\cheng>echo %CMDCMDLINE%
"C:\Windows\system32\cmd.exe"
C:\Users\cheng>
C:\Users\cheng>echo %COMPUTERNAME%
YONGQIANG
C:\Users\cheng>
C:\Users\cheng>echo %PROCESSOR_REVISION%
9e0a
C:\Users\cheng>
%USERPROFILE%
– C:\Users\<username>
%USERDOMAIN%
– Userdomain associated with current user.
%USERDOMAIN_ROAMINGPROFILE%
– Userdomain associated with roaming profile.
%PUBLIC%
– C:\Users\Public
%PSMODULEPATH%
– %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\
%ONEDRIVE%
– C:\Users\<username>\OneDrive
%CMDCMDLINE%
– Outputs command line used to launch the current Command Prompt session.
%COMPUTERNAME%
-Outputs the system name.
%PROCESSOR_REVISION%
– Outputs processor revision.
Microsoft Windows [版本 10.0.17763.1158]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\Users\cheng>echo %PROCESSOR_IDENTIFIER%
Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
C:\Users\cheng>
C:\Users\cheng>echo %PROCESSOR_LEVEL%
6
C:\Users\cheng>
C:\Users\cheng>echo %RANDOM%
25197
C:\Users\cheng>
C:\Users\cheng>echo %NUMBER_OF_PROCESSORS%
12
C:\Users\cheng>
C:\Users\cheng>echo %OS%
Windows_NT
C:\Users\cheng>
%PROCESSOR_IDENTIFIER%
– Outputs processor identifier.
%PROCESSOR_LEVEL%
– Outputs processor level.
%RANDOM%
– This variable prints a random number from 0 through 32767
%NUMBER_OF_PROCESSORS%
– Outputs the number of physical and virtual cores.
%OS%
– Windows_NT
References
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/192313.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...