environment variable

Specify parameters of operating system running environment
Collection
zero Useful+1
zero
Environmental Science Environment variables Generally refers to operating system Some parameters used to specify the operating system running environment in, such as: Temporary folder Location and System folder Location, etc.
Environmental Science variable An object with a specific name in the operating system, which contains one or more applications program Information to be used. for example Windows and DOS The path environment variable in the operating system, when the system is required to run a program When the system does not tell it the full path where the program is located, except in the current directory In addition to this program, you should also go to the path specified in the path. Users can set the environment variable To run the process better.
Chinese name
Environmental Science variable
Foreign name
environment variables
Applied discipline
Computer software
Properties
Object OBJECT
Source
operating system

Main role

Announce
edit

Set parameters

Environment variables are equivalent to application program The specific functions of some parameters set depend on the specific environment variables. For example, path tells the system that when the system is required to run a program without telling it the full path of the program, the system will not only current directory In addition to this program, what directories should we look for; Another example is tc or vc++ Medium, set include=path1;path2; Is to tell Compiler Where to find files of type. h; Of course, it is not only for specifying the path, but also for other purposes. For example, set dircmd=/4 is used to set an environment variable command The/4 parameter will be added to your dir command as the default parameter. Just like every command you add the/4 parameter, it actually gives commands Interpreter An environment variable set by the command and given to dir Internal commands Set.
DWORD GetEnvironmentVariable (LPCSTR lpName, LPSTR lpBuffer, DWORD dSize), The parameter lpName is the environment you want to query variable LpBuffer returns the value of the environment variable you specified, and dSize tells this function How many bytes can lpBuffer store.
When analyzing local faults, it is likely that the cause is the environment variable The result of deleting the default path in. Once the default path is set, if any program Some DLLs or EXE files are needed during the run time, and Active controls will be searched in all default paths catalog If the corresponding program is found in, it will be automatically loaded. If it cannot be found, it will be reported that the error message

Software sharing

Many friends will be in their own computer Install dual systems on the, such as C disk installation Windows XP , D-disk installation Windows 7 But some Software Usually, it is only installed in Windows XP system, but it cannot be used normally in Windows 7 system. The troublesome but effective method is to install it again. When we understand the environment variable It can solve the problem of dual system Software Shared questions.

System operation

Why is the Software Can't run under Windows 7( Green software Except)? The reason is that when installing software, it is often necessary to catalog Some files are copied in the, but cannot run when using another system due to the lack of these files. Therefore, we can set the environment variable To solve this problem.

Common variables

Announce
edit
WINDOWS system
%ALLUSERSPROFILE% returns all locally“ User Profile ”Location of.
%APPDATA% returns default locally situation lower application program The location where the data is stored.
%CD% Local Return current directory character string.
%CMDCMDLINE% partially returns the accuracy used to start the current Cmd.exe command that 's ok.
%CMDEXTVERSION% The system returns the current“ command handle program Extension.
%COMPUTERNAME% system returns computer The name of the.
%COMSPEC% System Return Command Line Interpreter Executable program The exact path of.
%DATE% The system returns the current date Use with date/t command Same format. Generated by Cmd.exe. About date command For details, see Date.
%ERRORLEVEL% The system returns used command Of error code Errors are usually represented by non-zero values.
%HOMEDRIVE% The system returns the connection to the user catalog The local workstation drive letter of the. Based on main catalog Value setting. User main catalog Is specified in Local Users and Groups.
%HOMEPATH% system returns the user catalog The full path of. Based on main catalog Value setting. User main catalog Is on“ Local Users and Groups ”Specified in.
%HOMESHARE% The system returns the user's sharer catalog The network path of. Based on main catalog Value setting. User main catalog Is specified in Local Users and Groups.
%LOGONSEVER% returns the part that verifies the current login session domain controller The name of the.
%NUMBER_OF_PROCESSORS% is specified to be installed in computer The number of processors on.
%OS% System Return operating system The name of the. Windows 2000 take operating system Displayed as Windows_NT.
%PATH% system designation Executable The search path for.
%PATHEXT% system return operating system Deemed enforceable File extension List of.
%PROCESSOR_ARCHITECTURE% The system returns the processor's chip architecture. Value: x86, IA64
%PROCESSOR_IDENTIFIER% The system returned the processor description.
%PROCESSOR_LEVEL% system returns computer The model of the processor installed on the.
%PROCESSOR_REVISION% The system returns System variable
%PROMPT% returns current locally Interpreter Of command prompt set up. Generated by Cmd.exe.
%RANDOM% system returns any value between 0 and 32767 decimal system Number. from Cmd.exe Build.
%SYSTEMDRIVE% System return contains Windows XP root catalog (i.e. system root directory) Driver
%SYSTEMROOT% system returns Windows XP root catalog Location of.
%TEMP% and% TMP% The system and user return the available application program Default temporary used catalog Some application program TEMP is required, while other applications require TMP.
%TIME% The system returns the current time. Use the same format as the time/t command. Generated by Cmd.exe. About time command For details, see Time.
%USERDOMAIN% Local return contains User account The name of the domain for.
%USERNAME% returns the name of the currently logged in user locally.
%UserProfile% returns the location of the current user's profile locally.
%WINDIR% system returns operating system catalog Location of. [1]
Linux system
shell The environment depends on the settings of multiple files. When the shell is called, it reads from two initial files command 。/ The etc/profile contains System variable , which is system administrator Maintenance, the system administrator sets local system variables and special command Startup of ordinary users Information file ($HOME/. bash_project) is maintained by each user. This file can be modified to implement any specific System Initialization
Only in specific situation The profile file is read only when the user logs in. After running the shell script or subshell, you don't need to read the profile. Although all profiles are optional, almost all systems have/etc/profile
If defined variable ENV and has been transferred to the environment, all bash shells should read and call the command This file is used to define the characteristics of all bash shells, not just login to the shell. The typical name of this file is $HOME/, bashrc.
Used( system administrator )When creating a new user,. bash_profile, bashrc and other public environment file templates will be copied to/etc/skel catalog below. You can edit these initialization settings or catalog Add additional files under.
Example:
A typical system profile (/etc/profile):
PATH=$PATH:/usr/qa/tools/bin
ENV==$HOME/.bashrc
ORACLE_HOME=/dbs/oracle
ORACLE_SID=qadb
Export PATH ENV ORACLE_HOME ORCAL_SID
Cat /etc/motd
A typical user profile (. bashrc)
PATH=$PATH:$HOME/bin
TEAM=uvt1224 export TERM
cal
A typical user bashrc file (. bashrc):
alias dir=ls lf='ls -FC'
PSI='$PWS[!]>'
set -o vi
Aliases and other special definitions for bash should be defined in the. bashrc file (not in the. bash_profile); Otherwise, some will not be found command
You should remember the difference between the profile file and the. bashrc file: both profiles are read only once when the system starts, while. bashrc is read when the system starts and every time you call the shell.

Setting method

Announce
edit
On windows operating system Can be accessed through My Computer ->System Properties>Advanced System Settings>Environment Variables to set the system environment variable However, does the environment variable set here have a corresponding key in the registry? The answer is yes. A class is provided in. net to obtain the system environment variable And its value.
Environmental Science variable There are two categories: user variables and System variable , there are corresponding entries in the registry.
Where users variable Location:
HKEY_CURRENT_USER \Environment;
System variable Location:\ HKEY_LOCAL_MACHINE \SYSTEM\ControlSet001
\Control\Session Manager\Environment。
You can also right click My Computer ——Advanced System Settings - Environment variable ——On System variable There is the path option - double click to open - add semicolons in English status on the basis of the original variables - and then enter the path name. (Remember not to delete the original System variable , just use semicolons to separate, then add, and finally add semicolons) [1]

Edit Method

Announce
edit
How to edit environment variables on the command line
View all currently available environments variable (= System variable +User variable)
set
View an environment variable , such as PATH
set PATH
Add Environment variable , e.g. xxx=aa
set xxx=aa
Set the environment variable (e.g. xxx) is set to null
set xxx=
In an environment variable (such as PATH), add a new value (such as d: xxx)
set PATH=%PATH%;d:\xxx
(Note: In the dos window, use command Line mode versus environment variable The operation of is only valid for the application of the current window)