{"id":177,"date":"2013-03-23T08:38:26","date_gmt":"2013-03-23T00:38:26","guid":{"rendered":"http:\/\/bohu.net\/blog\/?p=177"},"modified":"2013-03-23T08:38:26","modified_gmt":"2013-03-23T00:38:26","slug":"windows-%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f","status":"publish","type":"post","link":"https:\/\/www.bohu.net\/blog\/177\/","title":{"rendered":"windows \u73af\u5883\u53d8\u91cf"},"content":{"rendered":"<p>Getting and setting environment variables<\/p>\n<p>The variables can be used both in scripts and on the <a title=\"Command line\" href=\"http:\/\/en.wikipedia.org\/wiki\/Command_line\">command line<\/a>. They are usually referenced by putting special symbols in front of or around the variable name. For instance, to display the user home directory, in most scripting environments, the user has to type:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>echo $HOME<\/pre>\n<\/div>\n<\/div>\n<p>On <a title=\"COMMAND.COM\" href=\"http:\/\/en.wikipedia.org\/wiki\/COMMAND.COM\">DOS<\/a>, <a title=\"Command Prompt\" href=\"http:\/\/en.wikipedia.org\/wiki\/Command_Prompt\">OS\/2 or Windows<\/a> systems, the user has to type this:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>echo %HOME%<\/pre>\n<\/div>\n<\/div>\n<p>In <a title=\"Windows PowerShell\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_PowerShell\">Windows PowerShell<\/a>, the user has to type this:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>Write-Output $HOME<\/pre>\n<\/div>\n<\/div>\n<h3>DOS, OS\/2 and Windows (Command Prompt)<\/h3>\n<p>In DOS, OS\/2 and Windows, the <b><code>set<\/code><\/b> command without any arguments displays all environment variables along with their values.<\/p>\n<p>To set a variable to a particular value, use:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>set VARIABLE=value<\/pre>\n<\/div>\n<\/div>\n<p>However, this is temporary. Permanent change to the environment variable can be achieved through editing the registry (not recommended for novices) and using the Windows <a title=\"Resource Kit\" href=\"http:\/\/en.wikipedia.org\/wiki\/Resource_Kit\">Resource Kit<\/a> application <code>setx.exe<\/code>. With the introduction of <a title=\"Windows Vista\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_Vista\">Windows Vista<\/a>, the <code>setx<\/code> command became part of Windows.<\/p>\n<p>Users of the Windows GUI can manipulate variables via &lt;Control Panel:System:Advanced:Environment Variables&gt;; through the <a title=\"Windows Registry\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_Registry\">Windows Registry<\/a> this is done changing the values under HKCU\\Environment (for user specific variables) and HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment (for System variables).<\/p>\n<p>To set a variable whose name is in another variable:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>set %VARNAME%=value<\/pre>\n<\/div>\n<\/div>\n<p>This feature allows certain interesting applications. For example, a uni-dimensional array of elements (vector) may be generated this way:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>set VECTOR[%I%]=value of element subscript %I%\n\n:MkVec\nset VECNAME=%1\nset i=0\n:loop\n    shift\n    if \"%1\" == \"\" goto exitloop\n    set \/a i+=1\n    set %VECNAME%[%i%]=%1\n    goto loop\n:exitloop\nexit \/B %i%\n\ncall :MkVec DOWNAME=Monday Tuesday Wednesday Thursday Friday Saturday Sunday<\/pre>\n<\/div>\n<\/div>\n<p>To see the current value of a particular variable, use:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>echo %VARIABLE%<\/pre>\n<\/div>\n<\/div>\n<p>or<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>set VARIABLE<\/pre>\n<\/div>\n<\/div>\n<p>Note: Please take note that doing so will print out all variables beginning with &#8216;VARIABLE&#8217;. Another example is:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>C:\\&gt; set p\nPath=c:\\.. ..\nPATHEXT=.COM;.EXE;.BAT;\nPROCESSOR_ARCHITECTURE=.. ..\nPROCESSOR_IDENTIFIER=x8..\nPROCESSOR_LEVEL=6..\nPROCESSOR_REVISION=1706..\nProgramFiles=C:\\Program.. .\nPROMPT=$P$G<\/pre>\n<\/div>\n<\/div>\n<p>To see the value of an array element a double expansion is required: one for the subscript value and an additional expansion for the array element. This may be achieved via Delayed\u00a0!VARIABLE! Expansion this way:<\/p>\n<pre>set DOW=value of Day of Week (1..7)\necho !DOWNAME[%DOW%]!<\/pre>\n<p>To delete a variable, the following command is used:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>set VARIABLE=<\/pre>\n<\/div>\n<\/div>\n<h3>Windows PowerShell<\/h3>\n<p>To set a system variable:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>Set-Content -Path Env:VARIABLE -value value\n$Env:VARIABLE = value # alternate form<\/pre>\n<\/div>\n<\/div>\n<h4>Examples of DOS environment variables<\/h4>\n<dl>\n<dt><a title=\"ComSpec\" href=\"http:\/\/en.wikipedia.org\/wiki\/ComSpec\">%COMSPEC%<\/a><\/dt>\n<\/dl>\n<p>This variable contains the full path to the <a title=\"Command processor\" href=\"http:\/\/en.wikipedia.org\/wiki\/Command_processor\">command processor<\/a>, <a title=\"Command.com\" href=\"http:\/\/en.wikipedia.org\/wiki\/Command.com\">command.com<\/a>.<\/p>\n<dl>\n<dt>%PATH%<\/dt>\n<\/dl>\n<p>This variable contains a semicolon-delimited list of directories in which the <a title=\"Command interpreter\" href=\"http:\/\/en.wikipedia.org\/wiki\/Command_interpreter\">command interpreter<\/a> will search for <a title=\"Executable file\" href=\"http:\/\/en.wikipedia.org\/wiki\/Executable_file\">executable files<\/a>. Equivalent to the Unix $PATH variable (although note that PATH on Windows additionally performs the same task as LD_LIBRARY_PATH on Unix-like systems). Note that\u00a0%PATH% can also be set like this PATH=c:\\dos; where SET isn&#8217;t required.<\/p>\n<dl>\n<dt>%TEMP% and\u00a0%TMP%<\/dt>\n<\/dl>\n<p>These variables contain the path to the directory where <a title=\"Temporary file\" href=\"http:\/\/en.wikipedia.org\/wiki\/Temporary_file\">temporary files<\/a> should be stored.<\/p>\n<h3>Examples from Microsoft Windows<\/h3>\n<h4>Discrete value variables<\/h4>\n<p>These variables generally expand to discrete values, such as the <a title=\"Working directory\" href=\"http:\/\/en.wikipedia.org\/wiki\/Working_directory\">current working directory<\/a>, the current date, or a random number. Some of these are true environment variables and will be expanded by all functions that handle environment variables. Others, like\u00a0%CD% simply look like environment variables and will only be expanded by some functions and shells. They are not case sensitive.<\/p>\n<dl>\n<dt>%CD%<\/dt>\n<\/dl>\n<p>This variable points to the current directory. Equivalent to the output of the command <tt>cd<\/tt> when called without arguments.<\/p>\n<dl>\n<dt>%DATE%<\/dt>\n<\/dl>\n<p>This variable expands to the current date. The date is displayed according to the current user&#8217;s <a title=\"Calendar date\" href=\"http:\/\/en.wikipedia.org\/wiki\/Calendar_date\">date format<\/a> preferences.<\/p>\n<p>The following is a way of reformatting the date and time for use in file copies. The example assumes UK format of day month year and the time is set for a 24 hour clock.<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>@echo off\necho %DATE% %TIME%\nfor \/F \"tokens=1-3 delims=\/\" %%a in (\"%DATE%\") do set MTH=%%a&amp; set DAY=%%b&amp; set YR=%%c\nfor \/F \"tokens=1-3 delims=:.\" %%a in (\"%TIME%\") do set HR=%%a&amp; set MIN=%%b&amp; set SEC=%%c\nif \"%HR:~0,1%\"==\" \" set HR=0%HR:~1,1%\nset MYDATE=%YR%%MTH%%DAY%-%HR%%MIN%%SEC%\necho %MYDATE%<\/pre>\n<\/div>\n<\/div>\n<dl>\n<dt>%ERRORLEVEL%<\/dt>\n<\/dl>\n<p>This variable points to the current error level. If there was an error in the previous command, it is checked against this.<\/p>\n<dl>\n<dt>%RANDOM%<\/dt>\n<\/dl>\n<p>This variable returns a random number between 0 and 32767.<\/p>\n<dl>\n<dt>%TIME%<\/dt>\n<\/dl>\n<p>This variable points to the current time. The time is displayed according to the current user&#8217;s time format preferences.<\/p>\n<h4>System path variables<\/h4>\n<p>These variables refer to locations of critical operating system resources, and as such generally are not user-dependent.<\/p>\n<dl>\n<dt>%AppData%<\/dt>\n<\/dl>\n<p>Contains the full path to the <a title=\"Special Folders\" href=\"http:\/\/en.wikipedia.org\/wiki\/Special_Folders\">Application Data<\/a> directory of the logged-in user. Does not work on Windows NT 4.0 SP6 UK.<\/p>\n<dl>\n<dt>%LOCALAPPDATA%<\/dt>\n<\/dl>\n<p>This variable is the temporary files of Applications. Its uses include storing of <a title=\"Theme (computing)\" href=\"http:\/\/en.wikipedia.org\/wiki\/Theme_(computing)\">Desktop Themes<\/a>, <a title=\"Windows Error Reporting\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_Error_Reporting\">Windows Error Reporting<\/a>, Caching and profiles of web browsers.<\/p>\n<dl>\n<dt>%<a title=\"ComSpec\" href=\"http:\/\/en.wikipedia.org\/wiki\/ComSpec\">ComSpec<\/a>%<\/dt>\n<\/dl>\n<p>This variable contains the full path to the command processor; on Windows NT based operating systems this is <tt>cmd.exe<\/tt>, while on Windows 9x and ME it is the DOS command processor, <tt>COMMAND.COM<\/tt>.<\/p>\n<dl>\n<dt>%PATH%<\/dt>\n<\/dl>\n<p>This variable contains a semicolon-delimited (do not put spaces in between) list of directories in which the command interpreter will search for an executable file that matches the given command. Equivalent to the <a title=\"Unix\" href=\"http:\/\/en.wikipedia.org\/wiki\/Unix\">Unix<\/a> <tt>$PATH<\/tt> variable.<\/p>\n<dl>\n<dt>%ProgramFiles%<\/dt>\n<\/dl>\n<p>This variable points to Program Files directory, which stores all the installed program of Windows and others. The default on English-language systems is <tt>C:\\Program Files<\/tt>. In 64-bit editions of Windows (XP, 2003, Vista), there are also <b>%ProgramFiles(x86)%<\/b> which defaults to <tt>C:\\Program Files (x86)<\/tt> and <b>%ProgramW6432%<\/b> which defaults to <tt>C:\\Program Files<\/tt>. The\u00a0%ProgramFiles% itself depends on whether the process requesting the environment variable is itself 32-bit or 64-bit (this is caused by <a title=\"WoW64\" href=\"http:\/\/en.wikipedia.org\/wiki\/WoW64\">Windows-on-Windows 64-bit<\/a> redirection).<\/p>\n<dl>\n<dt>%CommonProgramFiles%<\/dt>\n<\/dl>\n<p>This variable points to Common Files directory. The default is <tt>C:\\Program Files\\Common Files<\/tt>.<\/p>\n<dl>\n<dt>%SystemDrive%<\/dt>\n<\/dl>\n<p>The\u00a0%SystemDrive% variable is a special system-wide environment variable found on <a title=\"Microsoft\" href=\"http:\/\/en.wikipedia.org\/wiki\/Microsoft\">Microsoft<\/a> <a title=\"Windows NT\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_NT\">Windows NT<\/a> and its derivatives. Its value is the drive upon which the system directory was placed. Also see next item.<\/p>\n<p>The value of\u00a0%SystemDrive% is in most cases <tt>C:<\/tt>.<\/p>\n<dl>\n<dt>%SystemRoot%<\/dt>\n<\/dl>\n<p>The\u00a0%SystemRoot% variable is a special system-wide environment variable found on Microsoft Windows NT and its derivatives. Its value is the location of the system directory, including the drive and path.<\/p>\n<p>The drive is the same as\u00a0%SystemDrive% and the default path on a clean installation depends upon the version of the operating system. By default, on a clean installation:<\/p>\n<ul>\n<li>Windows NT 5.1 (<a title=\"Windows XP\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_XP\">Windows XP<\/a>) and newer versions use <tt>\\WINDOWS<\/tt><\/li>\n<li>Windows NT 5.0 (<a title=\"Windows 2000\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_2000\">Windows 2000<\/a>), Windows NT 4.0 and Windows NT 3.1 use <tt>\\WINNT<\/tt><\/li>\n<li>Windows NT 3.5x uses <tt>\\WINNT35<\/tt><\/li>\n<li>Windows NT 4.0 Terminal Server use <tt>\\WTSRV<\/tt><\/li>\n<\/ul>\n<dl>\n<dt>%WinDir%<\/dt>\n<\/dl>\n<p>This variable points to the Windows directory (on Windows NT-based operating systems it is identical to the\u00a0%SystemRoot% variable, above). If the System is on drive C: then the default values are:<\/p>\n<ul>\n<li><tt>C:\\WINDOWS<\/tt> on <a title=\"Windows 95\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_95\">Windows 95<\/a>, <a title=\"Windows 98\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_98\">Windows 98<\/a>, <a title=\"Windows Me\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_Me\">Windows Me<\/a>, <a title=\"Windows XP\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_XP\">Windows XP<\/a>, <a title=\"Windows Server 2003\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_Server_2003\">Windows Server 2003<\/a>, <a title=\"Windows Vista\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_Vista\">Windows Vista<\/a>, <a title=\"Windows Server 2008\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_Server_2008\">Windows Server 2008<\/a> and <a title=\"Windows 7\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_7\">Windows 7<\/a><\/li>\n<li><tt>C:\\WINNT<\/tt> for <a title=\"Windows NT 4\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_NT_4\">Windows NT 4<\/a>, and Windows 2000<\/li>\n<\/ul>\n<p>Note that Windows NT 4 Terminal Server Edition by default installs to <tt>C:\\WTSRV<\/tt>.<\/p>\n<h4>User management variables<\/h4>\n<p>These variables store information related to resources and settings owned by various <a title=\"User profile\" href=\"http:\/\/en.wikipedia.org\/wiki\/User_profile\">user profiles<\/a> within the system. As a general rule, these variables do not refer to critical system resources or locations that are necessary for the OS to run.<\/p>\n<dl>\n<dt>%AllUsersProfile% (%PROGRAMDATA% for Windows Vista, Windows 7)<\/dt>\n<\/dl>\n<p>The\u00a0%AllUsersProfile%(%PROGRAMDATA%) variable expands to the full path to the All Users profile directory. This profile contains resources and settings that are used by all system accounts. <a title=\"Computer shortcut\" href=\"http:\/\/en.wikipedia.org\/wiki\/Computer_shortcut\">Shortcut<\/a> links copied to the All Users&#8217; Start menu or Desktop directories will appear in every user&#8217;s Start menu or <a title=\"Desktop metaphor\" href=\"http:\/\/en.wikipedia.org\/wiki\/Desktop_metaphor\">Desktop<\/a>, respectively.<\/p>\n<dl>\n<dt>%UserDomain%<\/dt>\n<\/dl>\n<p>The variable holds the name of the <a title=\"Workgroup\" href=\"http:\/\/en.wikipedia.org\/wiki\/Workgroup\">Workgroup<\/a> or <a title=\"Windows Server domain\" href=\"http:\/\/en.wikipedia.org\/wiki\/Windows_Server_domain\">Windows Domain<\/a> to which the current user belongs. The related variable,\u00a0%LOGONSERVER%, holds the <a title=\"Hostname\" href=\"http:\/\/en.wikipedia.org\/wiki\/Hostname\">hostname<\/a> of the server that authenticated the current user&#8217;s logon credentials (name and password). For Home PCs, and PCs in a Workgroup, the authenticating server is usually the PC itself. For PCs in a Windows Domain, the authenticating server is a <a title=\"Domain controller\" href=\"http:\/\/en.wikipedia.org\/wiki\/Domain_controller\">domain controller<\/a> (a primary domain controller, or PDC, in Windows NT 4-based domains).<\/p>\n<dl>\n<dt>%UserProfile%<\/dt>\n<\/dl>\n<p>The\u00a0%UserProfile% variable is a special system-wide environment variable found on Microsoft Windows NT and its derivatives. Its value is the location of the current user&#8217;s profile directory, in which is found that user&#8217;s HKCU registry hive (<tt>NTUSER<\/tt>).<\/p>\n<p>Users can also use the <b>%USERNAME%<\/b> variable to determine the active users login identification.<\/p>\n<h3>Windows GUI forced variable expansion<\/h3>\n<p>In certain cases it is not possible to create file paths containing environment variables using the Windows GUI, and it is necessary to fight with the user interface to make things work as intended.<\/p>\n<ul>\n<li>In Windows 7, a shortcut may not contain the variable\u00a0%USERNAME% in unexpanded form. Trying to create shortcut to <i>\\\\server\\share\\accounts\\%USERNAME%<\/i> or <i>C:\\users\\%USERNAME%<\/i> will be silently changed to replace\u00a0%USERNAME% with the account name of the currently logged-in user, when the OK button is pressed on the shortcut properties.\n<ul>\n<li>This can only be overridden if the\u00a0%USERNAME% variable is part of a parameter to some other program in the shortcut. For example, <i>%SYSTEMROOT%\\Explorer.exe C:\\Users\\%USERNAME%<\/i> is not expanded when OK is clicked, but this shortcut is treated as unsafe and displays a warning when opened.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li>In Group Policy Management on Server 2008 R2, a profile directory can not be redirected to a custom directory hierarchy. For example, the desktop can not be redirected to <i>\\\\server\\share\\accounts\\%USERNAME%\\custom\\path\\desktop<\/i>. Upon pressing OK, this is silently changed to &#8220;Create a directory for each user in the root path&#8221; with the path <i>\\\\server\\share\\accounts\\<\/i> pointing to &#8220;\\username\\desktop&#8221;.\n<ul>\n<li>This behavior can only be overridden if the path contains a variable or drive letter that is not currently resolvable at the time of editing the GPO. For example if a mapping for drive Z: does not exist on the server, then the path <i>Z:\\directory\\%username%\\CustomTarget<\/i> is not expanded when OK is selected.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li>A domain user account may not contain a profile path or home directory path containing an unexpanded\u00a0%USERNAME% variable. Upon clicking OK, this is silently replaced with the user&#8217;s account name.\n<ul>\n<li>This causes problems for new user creation that is performed by copying an existing user account, if there are additional directories listed after the username in the path. For a pre-existing account with a profile path of <i>\\server\\share\\accounts\\DomainUser\\profile<\/i> the Microsoft Management Console doesn&#8217;t know which part of the path contains the previous user&#8217;s name and doesn&#8217;t change the path during the copy, resulting in the new account pointing to the other account&#8217;s profile\/home paths. The profile\/home paths must be manually re-edited to point to the correct location.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Default Values on Microsoft Windows<\/p>\n<table>\n<tbody>\n<tr>\n<th>Variable<\/th>\n<th>Windows XP<\/th>\n<th>Windows Vista\/7<\/th>\n<\/tr>\n<tr>\n<td>\u00a0%ALLUSERSPROFILE%<\/td>\n<td>C:\\Documents and Settings\\All Users<\/td>\n<td>C:\\ProgramData<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%APPDATA%<\/td>\n<td>C:\\Documents and Settings\\{username}\\Application Data<\/td>\n<td>C:\\Users\\{username}\\AppData\\Roaming<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%COMPUTERNAME%<\/td>\n<td>{computername}<\/td>\n<td>{computername}<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%COMMONPROGRAMFILES%<\/td>\n<td>C:\\Program Files\\Common Files<\/td>\n<td>C:\\Program Files\\Common Files<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%COMMONPROGRAMFILES(x86)%<\/td>\n<td>C:\\Program Files (x86)\\Common Files <i>(only in 64-bit version)<\/i><\/td>\n<td>C:\\Program Files (x86)\\Common Files <i>(only in 64-bit version)<\/i><\/td>\n<\/tr>\n<tr>\n<td>\u00a0%COMSPEC%<\/td>\n<td>C:\\Windows\\System32\\cmd.exe<\/td>\n<td>C:\\Windows\\System32\\cmd.exe<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%HOMEDRIVE%<\/td>\n<td>C:<\/td>\n<td>C:<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%HOMEPATH%<\/td>\n<td>\\Documents and Settings\\{username}<\/td>\n<td>\\Users\\{username}<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%LOCALAPPDATA%<\/td>\n<td><\/td>\n<td>C:\\Users\\{username}\\AppData\\Local<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%LOGONSERVER%<\/td>\n<td>\\\\{domain_logon_server}<\/td>\n<td>\\\\{domain_logon_server}<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%PATH%<\/td>\n<td>C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;{plus program paths}<\/td>\n<td>C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;{plus program paths}<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%PATHEXT%<\/td>\n<td>.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.WSF;.WSH<\/td>\n<td>.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.msc<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%PROGRAMDATA%<\/td>\n<td><\/td>\n<td>\u00a0%SystemDrive%\\ProgramData<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%PROGRAMFILES%<\/td>\n<td>\u00a0%SystemDrive%\\Program Files<\/td>\n<td>\u00a0%SystemDrive%\\Program Files<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%PROGRAMFILES(X86)%<\/td>\n<td>\u00a0%SystemDrive%\\Program Files (x86) <i>(only in 64-bit version)<\/i><\/td>\n<td>\u00a0%SystemDrive%\\Program Files (x86) <i>(only in 64-bit version)<\/i><\/td>\n<\/tr>\n<tr>\n<td>\u00a0%PROMPT%<\/td>\n<td>Code for current command prompt format. Code is usually $P$G<\/td>\n<td>Code for current command prompt format. Code is usually $P$G<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%PSModulePath%<\/td>\n<td><\/td>\n<td>\u00a0%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\Modules\\<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%PUBLIC%<\/td>\n<td><\/td>\n<td>\u00a0%SystemDrive%\\Users\\Public<\/td>\n<\/tr>\n<tr>\n<td>{Drive}:\\$Recycle.Bin<\/td>\n<td>C:\\Recycle.Bin<\/td>\n<td>C:\\$Recycle.Bin<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%SystemDrive%<\/td>\n<td>C:<\/td>\n<td>C:<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%SystemRoot%<\/td>\n<td>The Windows directory, usually C:\\Windows, formerly C:\\WINNT<\/td>\n<td>\u00a0%SystemDrive%\\Windows<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%TEMP% and\u00a0%TMP%<\/td>\n<td>\u00a0%SystemDrive%\\Documents and Settings\\{username}\\Local Settings\\Temp<\/td>\n<td>\u00a0%SystemDrive%\\Users\\{username}\\AppData\\Local\\Temp<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%USERDOMAIN%<\/td>\n<td>{userdomain}<\/td>\n<td>{userdomain}<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%USERNAME%<\/td>\n<td>{username}<\/td>\n<td>{username}<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%USERPROFILE%<\/td>\n<td>\u00a0%SystemDrive%\\Documents and Settings\\{username}<\/td>\n<td>\u00a0%SystemDrive%\\Users\\{username}<\/td>\n<\/tr>\n<tr>\n<td>\u00a0%WINDIR%<\/td>\n<td>\u00a0%SystemDrive%\\Windows<\/td>\n<td>\u00a0%SystemDrive%\\Windows<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>In this list, there is no environment variable that refers to the location of the user&#8217;s My Documents directory, so there is no standard method for setting a program&#8217;s home directory to be the My Documents directory.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Getting and setting environment variables The variables &hellip; <a href=\"https:\/\/www.bohu.net\/blog\/177\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cwindows \u73af\u5883\u53d8\u91cf\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[134,145,245,396,417,418,459,532,551],"class_list":["post-177","post","type-post","status-publish","format-standard","hentry","category-23","tag-dos","tag-environment","tag-microsoft-windows","tag-variables","tag-windows","tag-windows-2","tag-459","tag-532","tag-551"],"_links":{"self":[{"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/posts\/177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/comments?post=177"}],"version-history":[{"count":0,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/posts\/177\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/media?parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/categories?post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/tags?post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}