Using the Command Line to Quickly Modify Windows 7 Environment Variables Tutorial

  
The most common way to view and modify environment variables is through my Computer
->Properties->Advanced, (see How to Modify < u>Windows
7 environment variable》). However, in fact, using the command line to modify, it will be more convenient and fast. The specific method is as follows:
1, view all available environment variables:

Enter set to view
2, view an environment variable:

Enter “set variable Name, you can, for example, want to view the value of the path variable, that is, enter set path
3, modify the environment variable:
input “set variable name=variable content” can, for example, set the path to &ldquo ;d:\ make.exe”, just type set path="d:\ make.exe". Note that this modification of the environment variable refers to overwriting the previous content with the current content, not appending. For example, when I set the path above, if I re-enter set path="c", and then look at the path path again, the value is "ld:;c:” instead of “d:\ make. Exe”;“c”.
4, set to empty:
input “set variable name = & rdquo; Such as “set path=” then the path is empty when viewing the path. Note that as already stated above, it only works in the current command line window. So when viewing the path, don't right click on "My Computer" & rdquo;——“Properties ........
5, append content to the variable (different from 3):
Enter “set variable name=% variable name%; variable content”. For example, to add a new path to path, type "set path=%path%;d:\ make.exe” to add d:\ make.exe to the path and execute "set path=%path again %;c:", then, when using the set path statement to view, there will be: d:\ make.exe;c: instead of only c: as in step 3.
Appendix: Commonly Used Environment Variables and Roles
%ALLUSERSPROFILE% Partially Returns the location of all “user profiles”.
%APPDATA% Local Returns the location where the application stores data by default.
%CD% Local Returns the current directory string.
%CMDCMDLINE% Partial Returns the exact command line used to start the current Cmd.exe.
%CMDEXTVERSION% System Returns the current version number of the "Command Handler Extension".
%COMPUTERNAME% System Returns the name of the computer.
%COMSPEC% System Returns the exact path to the command line interpreter executable.
%DATE% System Returns the current date. Use the same format as the date /t command. Generated by Cmd.exe. For more information on the date command, see Date.
%ERRORLEVEL% System Returns the error code of the most recently used command. A non-zero value is usually used to indicate an error.
%HOMEDRIVE% System Returns the local workstation drive number that is connected to the user's home directory. Based on the settings of the home directory value. The user's home directory is specified in “Local Users and Groups".
%HOMEPATH% System Returns the full path to the user's home directory. Based on the settings of the home directory value. The user's home directory is specified in “Local Users and Groups".
%HOMESHARE% System Returns the network path of the user's shared home directory. Based on the settings of the home directory value. The user's home directory is specified in “Local Users and Groups".
%LOGONSEVER% Local Returns the name of the domain controller that authenticated the current login session.
%NUMBER_OF_PROCESSORS% System Specifies the number of processors installed on your computer.
%OS% System Returns the name of the OS
. Windows 2000 displays the operating system
as Windows_NT.
%PATH% System Specifies the search path for the executable.
%PATHEXT% System Returns a list of file extensions that the operating system considers executable.
%PROCESSOR_ARCHITECTURE% System Returns the processor's chip architecture. Value: x86, IA64.
%PROCESSOR_IDENTFIER% System Returns the processor description.
%PROCESSOR_LEVEL% System Returns the model number of the processor installed on your computer.
%PROCESSOR_REVISION% System Returns the system variable for the processor revision number.
%PROMPT% Local Returns the command prompt settings for the current interpreter. Generated by Cmd.exe.
%RANDOM% System Returns any decimal number between 0 and 32767. Generated by Cmd.exe.
%SYSTEMDRIVE% System Returns the drive containing the Windows XP root directory (that is, the system root).
%SYSTEMROOT% System Returns the location of the Windows XP root directory.
%TEMP% and %TMP% System and User Returns the default temporary directory used by the applications available to the currently logged in user. Some applications require TEMP, while others require TMP.
%TIME% System Returns the current time. Use the same format as the time /t command. Generated by Cmd.exe. For more information on the time command, see Time.
%USERDOMAIN% Partial Returns the name of the domain containing the user account.
%USERNAME% Local Returns the name of the currently logged in user.
%UserProfile% Local Returns the location of the current user's profile.
%WINDIR% System Returns the location of the operating system directory.

Copyright © Windows knowledge All Rights Reserved