1. What are environment variables?
To answer this question, the first thing to say is what is Windows Cmdshell. Because, environment variable is never the content that ordinary PC user cares about, most of the time, the environment variable is because Cmdshell only appears important.
Cmdshell--"command shell", is actually the command interpreter of Windows, it is responsible for the user input of the cmd (can be simply understood as a DOS command, although very narrow, inaccurate), corresponding to a DOS command execution, or a program to open. Help users run common Windows operations faster, such as browsing, managing files, executing applications, and getting rid of slow mouse actions. This does not have much appeal for average users, but it is important for programmers working under Windows.
From the Start menu--run-->cmd Open Command Prompt window, many people call it "XP DOS", not professional, but also harmless. It is like the Linux terminal, is the Cmdshell and User Communication window. Here, the user types cmd to the Shell,shell responsible for executing the corresponding command or program, and the execution of the return information immediately displayed on the window.
Now, with regard to what is Cmdshell, presumably you have learned that it is very similar to the Linux shell (BSH, CSH, tcsh, ksh, etc.), both in function and outside. Let's take a closer look at what the environment variables are.
In Cmdshell, we open a program (usually an. exe file) and need to write the full path of the program on the command line (after the prompt), such as "F:\Program Files\Microsoft Office\office11\ Winword.exe, and then enter to open the Word program. Here, it is easy to find that entering such a line of command is a very energetic thing, especially for a programmer who likes simple and efficient, so laborious things are too horrible to be imagined!
So, we are wondering, can we use a short instruction, like Winword, to replace the above-mentioned command? Of course, the Windows environment variable (environment variable) is a way to provide this! It specifies the search path for the command (program, executable), and when the shell does not find a program in the current directory that the user needs to execute, it goes to each directory specified by the environment variable and executes it after it has been found. In the example above, if we have F:\Program Files\Microsoft Office\office11\ This value in our environment variables, then when we winword this command to the shell input, The shell will open Word by locating the Winword.exe program (ignoring the suffix. exe) in the specified path.
In this case, you already know what a Windows environment variable is. In fact, the Windows environment variable will be more professionally referred to as aliases or placeholder, from the name can see its role, is not it? aliases--alias, compare image, in the above example, it is to give a very long command to a relatively very short name. placeholder, in essence, describes the role of environmental variables, "where to store (commands, programs)."
2. How do I set environment variables?
How to set environment variables: My Computer--right----high-level--environment variable-->XX's environment variable-->path--> Modify--Add the target path (note, Use semicolons to separate them from the previous values. Why, without this variable, please create a new one.)
Here, by the way, remind a detail: see? is the XX's environment variable, for other users of the same windows, regardless of the use of OH.
3. Perform common procedures
In general, Windows defaults to some path as the value of the environment variable, so you can open the program directly under that path, such as Calc Open calculator, Notepad open Notepad, and so on. If you add the MSOffice installation path to the environment variable, then you should be able to use Winword, Powerpnt, Excel to open Microsoft's Office Three Musketeers respectively. Similarly, you can easily open any program you like at the Cmdshell command prompt Wmplayer, gvim, and so on.
At the end, to say the same, the Windows environment variable (path) and the path variable under Linux (often set in the. cshrc file) are really not only shaped, but very similar. It is said that Linux and windows are too different, in fact, in many ways, they are still very similar.
This article is from the "Dongdongのhome" blog, make sure to keep this source http://autophp.blog.51cto.com/8062337/1637416
Windows environment variables