First make it clear:
All changes to the environment variable under the CMD command line are valid only for the current window , not for permanent modification. This means that when this cmd command-line window is closed, it will no longer work. There are two ways to permanently modify environment variables: One is to modify the registry directly (this method has not been tested at this time), and the other is to set the system's environment variables (see details) by using My Computer-Properties-〉 advanced.
Second, clarify the role of environmental variables.
It is a parameter that the operating system uses to specify the running environment. such as temporary folder location and System folder location. When you run some programs, in addition to looking in the current folder, but also to these environment variables to find, such as "Path" is a variable, which stores some common commands stored in the directory path.
Third: Under what circumstances are settings made?
When the cmd Command Line window to invoke a command, often "XXX is not an internal or external command, or a running program or batch file", if your spelling is not wrong, and the computer does exist in this program, then the hint is that your PATH variable is not set correctly, Because your path, also is the default path does not have your program, and you have not given the absolute path of your program (because you just entered the name of the command or program), this is the operating system do not know where to find your program, it will prompt this problem.
IV: How to modify?
1. View all currently available environment variables : Enter set to view.
2. View an environment variable: Enter "Set variable name", for example, to see the value of the path variable, that is, enter the set path
3, Modify the environment variable : Enter "Set Variable name = variable content", such as set path to "D:\nmake.exe", as long as the input set path= "D:\nmake.exe". Note that this modified environment variable refers to the current content to overwrite the previous content, not append. For example, when I set the path above, if I re-enter set path= "C" again, when I look at the path, the value is "C:" instead of "D:\nmake.exe"; "C".
4. set to NULL : If you want to set a variable to NULL, enter "Set Variable name =". If "Set path=" then look at the path is empty. Note that the above has been said to work only in the current command-line window. So don't right-click on "My Computer"-"properties" when viewing path.
5. append content to variable (different from 3, that is overwrite): enter "Set variable name =% variable name%; variable Contents". For example, to add a new path for path, enter "Set path=%path%;d: \nmake.exe" to add D:\nmake.exe to path and execute "set Path=%path%;c:" Again, then use the set Path statement to view, there will be: d:\nmake.exe;c: Instead of just C: in the 3rd step.
Appendix: The following some commonly used environmental variables and functions
%allusersprofile% returns the location of all user profiles locally.
%appdata% Local returns the location by default where the application stores data.
%cd% returns the current directory string locally.
%cmdcmdline% Local returns the exact command line used to start the current Cmd.exe.
The%cmdextversion% system returns the version number of the current command handler extension.
The%computername% system returns the name of the computer.
The%comspec% system returns the exact path to the command-line interpreter executable program.
The%date% system returns the current date. Use the same format as the date/t command. Generated by Cmd.exe. For more information about the date command, see Date.
The%errorlevel% system returns the error code for the most recently used command. Errors are usually indicated by a value other than 0.
The%homedrive% system returns the local workstation drive letter that is connected to the user's home directory. Settings based on the home directory value. The user home directory is specified in Local Users and groups.
The%homepath% system returns the full path of the user's home directory. Settings based on the home directory value. The user home directory is specified in Local Users and groups.
The%homeshare% system returns the network path of the user's shared home directory. Settings based on the home directory value. The user home directory is specified in Local Users and groups.
%logonsever% Local returns the name of the domain controller that validates the current logon session.
The%number_of_processors% system specifies the number of processors installed on the computer.
The%os% system returns the name of the operating system. Windows 2000 displays the operating system as WINDOWS_NT.
The%PATH% system specifies the search path for the executable file.
The%pathext% system returns a list of file name extensions that the operating system considers executable.
The%processor_architecture% system returns the chipset architecture of the processor. Value: X86,ia64.
The%processor_identfier% system returns the processor description.
The%processor_level% system returns the model number of the processor installed on the computer.
The system variable that returns the processor revision number for the%processor_revision% system.
%prompt% returns the command prompt settings for the current interpreter locally. Generated by Cmd.exe.
The%random% system returns any decimal digits from 0 to 32767. Generated by Cmd.exe.
The%systemdrive% system returns a drive that contains the Windows XP root directory, which is the system root.
The%SYSTEMROOT% system returns the location of the Windows XP root directory.
The%temp% and%TMP% system and the user return the default temporary directory used by the application that is available to the currently logged-on user. Some applications require TEMP, while other applications require TMP.
The%time% system returns the current time. Use the same format as the time/t command. Generated by Cmd.exe. For more information about the time command, see time.
%userdomain% Local returns the name of the domain that contains the user account.
%USERNAME% Local returns the name of the currently logged-on user.
%UserProfile% Local Returns the location of the current user's profile.
The%WINDIR% system returns the location of the operating system directory.
How Windows can view, modify, delete, and add environment variables on the cmd command line