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:\hacker.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: \hacker.exe" to add D:\hacker.exe to path and execute "set Path=%path%;c:" Again, then use the set Path statement to view, there will be: d:\hacker.exe;c: Instead of just C: in the 3rd step.
%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.
You can also get environment variables in the form of code:
/** * * */package
com.zken.test;
/**
* @author Kenan.zhang */public
class Test2 {
/**
* @param
args
*/public static void Main (string[] args) {
System.out.println (system.getenv ());
System.out.println (System.getproperties ());
}
}
Output Result:
{userprofile=c:\users\kenan.zhang@99bill.com, Programdata=c:\programdata, userdnsdomain=99bill.com, PATHEXT=.COM; EXE;. BAT;. CMD;. VBS;. VBE;. JS;. JSE;. WSF;. WSH;. MSC, Windows_tracing_logfile=c:\bvtbin\tests\installpackage\csilogfile.log, java_home=d:\java\jdk1.8.0_60_64, NUT _suffixed_searching=1, Maven_home=d:\software_installed\maven\apache-maven-3.3.3-bin, ProgramFiles (x86) =C:\ Program Files (x86), windows_tracing_flags=3, Temp=c:\users\kenanz~1.com\appdata\local\temp, Systemdrive=c:, Programfiles=c:\program Files, path=d:/java/jre1.8.0_60/bin/client;d:/java/jre1.8.0_60/bin;d:/java/jre1.8.0_60/ Lib/i386;d:\software_installed\maven\apache-maven-3.3.3-bin\bin; C:\oraclexe\app\oracle\product\10.2.0\server\bin; C:\programdata\oracle\java\javapath;d:\java\jdk1.8.0_60_64\bin; C:\Windows\system32; C:\Windows; C:\Windows\System32\Wbem; C:\Windows\System32\WindowsPowerShell\v1.0\; C:\Program files\intel\wifi\bin\; C:\Program Files\Common Files\intel\wirelesscommon\; C:\Program Files (x86) \tortoisesvn\bin;d:\ Software installation directory \rational\common; C:\Program Files (x86) \IDM computer solutions\ultraedit\;D: \software_installed\;D: \myeclipse;, homedrive=c:, hac_ Client_install_path=d:\software_installed\union_hac\portalclients\, processor_revision=4501, USERDOMAIN=99BILL, Allusersprofile=c:\programdata, ratl_rthome=d:\ Software installation directory \rational\rational Test, Programw6432=c:\program Files, Processor_identifier=intel64 Family 6 Model Stepping 1, Genuineintel, Sessionname=console, tmp=c:\users\kenanz~1.com \AppData\Local\Temp, Commonprogramfiles=c:\program Files\Common Files, =::=::\, LOGONSERVER=\\SHPDC, PROCESSOR_ Architecture=amd64, Fp_no_host_check=no, Os=windows_nt, homepath=\users\kenan.zhang@99bill.com, PROCESSOR_LEVEL=6, Commonprogramw6432=c:\program Files\Common Files, localappdata=c:\users\kenan.zhang@99bill.com\appdata\local, Nutsuffix=1, computername=sh401030101504, Windir=c:\windows, Systemroot=c:\windows, Asl.log=Destination=file, Number_of_processors=4, Username=kenan.zhang, Public=c:\users\public, PsmodulEpath=c:\windows\system32\windowspowershell\v1.0\modules\, CommonProgramFiles (x86) =C:\Program Files (x86) \Common Files, Comspec=c:\windows\system32\cmd.exe, Appdata=d:\kenan.zhang\application Data} {Java.runtime.name=java (TM) SE Runtime environment, Sun.boot.library.path=d:\java\jdk1.6.0_29\jre\bin, JAVA.VM.VERSION=20.4-B02, java.vm.vendor= Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, Java.vm.name=java HotSpot (TM) 64-Bit Server VMs, File.encoding.pkg=sun.io, Sun.java.launcher=sun_standard, USER.COUNTRY=CN, Sun.os.patch.level=service Pack 1, Java.vm.specification.name=java Virtual machine specification, user.dir=d:\software_installed\ Apache-tomcat-7.0.64\webapps\weakreferencetest, JAVA.RUNTIME.VERSION=1.6.0_29-B11, java.awt.graphicsenv= Sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=d:\java\jdk1.6.0_29\jre\lib\endorsed, OS.ARCH=AMD64, Java.io.tmpdir=c:\users\kenanz~1.com\appdata\local\temp\, line.separator=, Java.vm.specification.vendor=sun MicrosysTEMs Inc., user.variant=, Os.name=windows 7, SUN.JNU.ENCODING=GBK, Java.library.path=d:\java\jdk1.6.0_29\bin; C:\Windows\Sun\Java\bin; C:\Windows\system32; C:\windows;d:/java/jre1.8.0_60/bin/client;d:/java/jre1.8.0_60/bin;d:/java/jre1.8.0_60/lib/i386;d:\software_ Installed\maven\apache-maven-3.3.3-bin\bin; C:\oraclexe\app\oracle\product\10.2.0\server\bin; C:\programdata\oracle\java\javapath;d:\java\jdk1.8.0_60_64\bin; C:\Windows\system32; C:\Windows; C:\Windows\System32\Wbem; C:\Windows\System32\WindowsPowerShell\v1.0\; C:\Program files\intel\wifi\bin\; C:\Program Files\Common Files\intel\wirelesscommon\; C:\Program Files (x86) \tortoisesvn\bin;d:\ software installation directory \rational\common; C:\Program Files (x86) \IDM computer solutions\ultraedit\;D: \software_installed\;D: \myeclipse;;., Java.specification.name=java Platform API specification, java.class.version=50.0, Sun.management.compiler=hotspot 64 -bit tiered Compilers, os.version=6.1, User.home=d:\kenan.zhang, user.timezone=, java.awt.printerjob= Sun.awt.windows.WPrinTerjob, File.encoding=utf-8, java.specification.version=1.6, java.class.path=d:\software_installed\ Apache-tomcat-7.0.64\webapps\weakreferencetest\bin, User.name=kenan.zhang, java.vm.specification.version=1.0, Sun.java.command=com.zken.test.test2, Java.home=d:\java\jdk1.6.0_29\jre, sun.arch.data.model=64, User.language=zh , Java.specification.vendor=sun Microsystems Inc., Awt.toolkit=sun.awt.windows.wtoolkit, java.vm.info=mixed mode, Java.version=1.6.0_29, Java.ext.dirs=d:\java\jdk1.6.0_29\jre\lib\ext; C:\Windows\Sun\Java\lib\ext, sun.boot.class.path=d:\java\jdk1.6.0_29\jre\lib\resources.jar;d:\java\jdk1.6.0_29\ Jre\lib\rt.jar;d:\java\jdk1.6.0_29\jre\lib\sunrsasign.jar;d:\java\jdk1.6.0_29\jre\lib\jsse.jar;d:\java\ Jdk1.6.0_29\jre\lib\jce.jar;d:\java\jdk1.6.0_29\jre\lib\charsets.jar;d:\java\jdk1.6.0_29\jre\lib\modules\ Jdk.boot.jar;d:\java\jdk1.6.0_29\jre\classes, Java.vendor=sun Microsystems Inc., File.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, Sun.io.unicode. Encoding=unicodelittle, Sun.cpu.endian=little, Sun.desktop=windows, SUN.CPU.ISALIST=AMD64}
getenv is an environment change that gets the system, and the variables that Windows sets in the system Properties--high-level--environment variable will be shown here (for Linux, variables set by export will be shown here) GetProperties is to obtain the relevant properties of the system, including file encoding, operating system name, region, user name, etc., this property is generally obtained automatically by the JVM and cannot be set.
the difference between CMD and DOS:
DOS is an operating system;
CMD is a human-computer interface inside the operating system, which simulates the DOS operating environment.
Essentially different, look and operate the same.
CMD is the abbreviation of command, also called the prompt mode, called MS-dos mode in Win98. However, CMD is not a real dos. It just operates the computer in a DOS manner. The command executed in CMD is actually a Windows command. Just a lot of Windows commands and DOS commands are the same.
When you enter a command, it is case-sensitive.