Environmental ScienceEnvironment variablesGenerally refers tooperating systemSome parameters used to specify the operating system running environment in, such as:Temporary folderLocation andSystem folderLocation, etc.
Environmental SciencevariableAn object with a specific name in the operating system, which contains one or more applicationsprogramInformation to be used.for exampleWindowsandDOSThe path environment variable in the operating system, when the system is required to run aprogramWhen the system does not tell it the full path where the program is located, except in thecurrent directoryIn addition to this program, you should also go to the path specified in the path.Users can set the environmentvariableTo run the process better.
Environment variables are equivalent toapplication programThe 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 onlycurrent directoryIn addition to this program, what directories should we look for;Another example is tc orvc++Medium,set include=path1;path2; Is to tellCompilerWhere 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 variablecommandThe/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 commandsInterpreterAn environment variable set by the command and given to dirInternal commandsSet.
DWORDGetEnvironmentVariable(LPCSTR lpName, LPSTR lpBuffer, DWORD dSize),The parameter lpName is the environment you want to queryvariableLpBuffer returns the value of the environment variable you specified, and dSize tells thisfunctionHow many bytes can lpBuffer store.
When analyzing local faults, it is likely that the cause is the environmentvariableThe result of deleting the default path in. Once the default path is set, if anyprogramSome DLLs or EXE files are needed during the run time, and Active controls will be searched in all default pathscatalogIf the corresponding program is found in, it will be automatically loaded. If it cannot be found, it will be reported that theerror message。
Software sharing
Many friends will be in their owncomputerInstall dual systems on the, such as C disk installationWindows XP, D-disk installationWindows 7。But someSoftwareUsually, 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 environmentvariableIt can solve the problem of dual systemSoftwareShared questions.
System operation
Why is theSoftwareCan't run under Windows 7(Green softwareExcept)?The reason is that when installing software, it is often necessary tocatalogSome files are copied in the, but cannot run when using another system due to the lack of these files.Therefore, we can set the environmentvariableTo solve this problem.
Common variables
Announce
edit
WINDOWS system
%ALLUSERSPROFILE% returns all locally“User Profile”Location of.
%DATE% The system returns the currentdate。Use with date/tcommandSame format.Generated by Cmd.exe.About datecommandFor details, see Date.
%ERRORLEVEL% The system returns usedcommandOferror code 。Errors are usually represented by non-zero values.
%HOMEDRIVE% The system returns the connection to the usercatalogThe local workstation drive letter of the.Based on maincatalogValue setting.User maincatalogIs specified in Local Users and Groups.
%HOMESHARE% The system returns the user's sharercatalogThe network path of.Based on maincatalogValue setting.User maincatalogIs specified in Local Users and Groups.
%LOGONSEVER% returns the part that verifies the current login sessiondomain controllerThe name of the.
%NUMBER_OF_PROCESSORS% is specified to be installed incomputerThe number of processors on.
%RANDOM% system returns any value between 0 and 32767decimal systemNumber.fromCmd.exeBuild.
%SYSTEMDRIVE% System return contains Windows XP rootcatalog(i.e. system root directory)Driver。
%SYSTEMROOT% system returns Windows XP rootcatalogLocation of.
%TEMP% and% TMP% The system and user return the availableapplication programDefault temporary usedcatalog。Someapplication programTEMP 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 timecommandFor details, see Time.
%USERDOMAIN% Local return containsUser accountThe 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.
shellThe environment depends on the settings of multiple files.When the shell is called, it reads from two initial filescommand。/The etc/profile containsSystem variable, which issystem administratorMaintenance, the system administrator sets local system variables and specialcommand。Startup of ordinary usersInformation file($HOME/. bash_project) is maintained by each user. This file can be modified to implement any specificSystem Initialization。
Only in specificsituationThe 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 definedvariableENV and has been transferred to the environment, all bash shells should read and call thecommand。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/skelcatalogbelow.You can edit these initialization settings orcatalogAdd additional files under.
Aliases and other special definitions for bash should be defined in the. bashrc file (not in the. bash_profile);Otherwise, some will not be foundcommand。
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 windowsoperating systemCan be accessed throughMy Computer->System Properties>Advanced System Settings>Environment Variables to set the system environmentvariableHowever, 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 environmentvariableAnd its value.
Environmental SciencevariableThere are two categories: user variables andSystem variable, there are corresponding entries in the registry.
You can also right clickMy Computer——Advanced System Settings - Environmentvariable——OnSystem variableThere 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 originalSystem 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