Windows Command Line cmd environment variable view, change, set

Source: Internet
Author: User
Tags xml parser

First, make it clear:
All changes to environment variables under the CMD command lineValid only for current windowIs not a permanent modification. That is to say, when the CMD command line window is closed, it will no longer work.Permanent modificationTwo methods are available for environment variables: one is to directly modify the Registry (this method has not been tested yet), and the other is through my computer-> properties-> advanced, to set system environment variables (View Details ).

Next, clarify the role of environment variables.
It is a parameter used by the operating system to specify the runtime environment. For example, the Temporary Folder location and the system folder location. When you run some programs, in addition to searching in the current folder, you will also search for these environment variables. For example, "path" is a variable, it stores directory paths for some common commands.

Third: under what circumstances?
When a command is called in the CMD command line window, "XXX is not an internal or external command, or a program or batch file that can be run" is often displayed ", if your spelling is correct and the program exists in the computer, the prompt is that your path variable is not correctly set because your path, that is, your program does not exist in the default path, and you have not given the absolute path of your program (because you just entered the command or program name ), this problem occurs when the operating system does not know where to find your program.

Fourth: how to modify it?
1,View all currently available Environment Variables: Enter set.
2. view an environment variable: Enter"Set variable nameFor example, to view the value of the PATH variable, enter set path
3. Modify the environment variable: Enter"Set variable name = variable content", For example, to set path to" D: \ nmake.exe ", just enter SET Path =" D: \ nmake.exe ". Note that this environment variable is used to overwrite the previous content, rather than append the content. For example, after setting the path above, if I re-enter SET Path = "C" and view the path again, the value is "C :", instead of "D: \ nmake.exe" and "C ".
4. Set to NULL: If you want to set a variable to null, enter"Set variable name =. For example, "set Path =" is empty when you view the path. Note: As mentioned above, it only works in the current command line window. Therefore, when viewing the path, do not right-click "my computer" -- "attribute "........
5. append the variable content (different from 3, which is overwrite): Enter"Set variable name = % variable name %; variable content". For example, to add a new path to path, enter "set Path = % PATH %; D: \ nmake.exe" to add D: \ nmake.exe to path, execute "set Path = % PATH %; C:" again. Then, when you use the set path statement to view it, there will be: D: \ nmake.exe; C :, instead of C :. For example:

Set Path = % PATH %; C: \ Program Files \ microsoft sdks \ windows \ v6.0a \ Lib; C: \ Program Files \ microsoft sdks \ windows \ v6.0a \ bin; C: \ Program Files \ microsoft sdks \ windows \ v6.0a \ include
Set include = % include %; C: \ Program Files \ microsoft sdks \ windows \ v6.0a \ include

Set Lib = % lib %; C: \ Program Files \ microsoft sdks \ windows \ v6.0a \ Lib

Set Lib = c: \ Program Files \ Microsoft XML Parser SDK \ Lib; C: \ Program Files \ Microsoft platform SDK \ Lib \; C: \ Program Files \ Microsoft Visual Studio \ vc98 \ MFC \ Lib; C: \ Program Files \ Microsoft Visual Studio \ vc98 \ Lib

Set Path = % PATH %; C: \ Program Files \ Microsoft Visual Studio \ common \ tools \ WINNT; C: \ Program Files \ Microsoft Visual Studio \ common \ msdev98 \ bin; C: \ Program Files \ Microsoft Visual Studio \ vc98 \ bin

Set include = c: \ Program Files \ Microsoft XML Parser SDK \ Inc; C: \ Program Files \ microsoft SDK \ include \; C: \ Program Files \ Microsoft Visual Studio \ vc98 \ ATL \ include; C: \ Program Files \ Microsoft Visual Studio \ vc98 \ MFC \ include; C: \ Program Files \ Microsoft Visual Studio \ vc98 \ include

Appendix: some common environment variables and their functions are attached below.

% Allusersprofile % returns all "user configuration files.
% Appdata % partial return the location where the application stores data by default.
% Cd % returns the current directory string.
% Cmdcmdline % returns the exact command line used to start the current cmd.exe.
% Cmdextversion % The system returns the version number of the current "command handler extension.
% Computername % the name of the computer returned by the system.
% Comspec % The system returns the exact path of the executable program of the command line interpreter.
% Date % The 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.
% Errorlevel % The system returns the error code of the recently used command. A non-zero value is usually used to indicate an error.
% Homedrive % The system returns the local workstation drive letter that is connected to the user's home directory. Set Based on the main directory value. The user home directory is specified in "local users and groups.
% Homepath % The system returns the complete path of the user's home directory. Set Based on the main directory value. The user's main directory is specified in "local users and groups"

Link from http://hi.baidu.com/myworkingemail/item/7c072d99ce00919759146102

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.