Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Environment variable
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==={{anchor|WIN-ENV}}Windows === These environment variables refer to locations of critical operating system resources, and as such generally are not user-dependent.<ref>{{cite web | url=https://learn.microsoft.com/en-us/windows/deployment/usmt/usmt-recognized-environment-variables | title=Recognized environment variables - Windows Deployment | date=9 January 2024 }}</ref> ;{{anchor|APPDATA}}<code>%APPDATA%</code><!-- all-uppercase at least under XP -->: Contains the full path to the ''[[Special folder|Application Data]]'' directory of the logged-in user. Does not work on Windows NT 4.0 SP6 UK. ;{{anchor|LOCALAPPDATA}}<code>%LOCALAPPDATA%</code>: This variable is the temporary files of ''Applications''. Its uses include storing of [[Theme (computing)|desktop themes]], [[Windows error reporting]], caching and profiles of web browsers. ;{{anchor|ComSpec|COMSPEC}}<code>%[[ComSpec]]%</code><!-- mixed case for CMD under XP -->/<code>%[[COMSPEC]]%</code>:The <code>%ComSpec%</code> variable contains the full path to the command processor; on the Windows NT family of operating systems, this is [[cmd.exe]], while on [[Windows 9x]], <code>%COMSPEC%</code> is [[COMMAND.COM]]. ;{{anchor|OS}}<code>%OS%</code>:The <code>%OS%</code> variable contains a symbolic name of the operating system family to distinguish between differing feature sets in [[batchjob]]s. It resembles an identically named environment variable <code>[[#%OS%|%OS%]]</code> found in all DOS-related operating systems of [[Digital Research]]-origin like Concurrent DOS, [[Multiuser DOS]], REAL/32, [[DOS Plus]], [[DR DOS]], Novell DOS and OpenDOS. <code>%OS%</code> always holds the string "<code>Windows_NT</code>" on the [[Windows NT family]].<ref name="Ten_XP"/> ;{{anchor|Path|PATH}}<code>%PATH%</code><!-- all-uppercase at least under XP -->: 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. Environment variables that represent paths may be nested within the <code>%PATH%</code> variable, but only at one level of indirection. If this sub-path environment variable itself contains an environment variable representing a path, <code>%PATH%</code> will not expand properly in the variable substitution. Equivalent to the [[Unix]] <code>[[#$PATH|$PATH]]</code> variable. ;{{anchor|PROCESSOR_ARCHITECTURE|PROCESSOR_ARCHITEW6432|PROCESSOR_IDENTIFIER|PROCESSOR_LEVEL|PROCESSOR_REVISION}}<code>%PROCESSOR_ARCHITECTURE%</code>, <code>%PROCESSOR_ARCHITEW6432%</code>, <code>%PROCESSOR_IDENTIFIER%</code>, <code>%PROCESSOR_LEVEL%</code>, <code>%PROCESSOR_REVISION%</code>: These variables contain details of the [[CPU]]; they are set during system installation. ;{{anchor|PUBLIC}}<code>%PUBLIC%</code>: The <code>%PUBLIC%</code> variable (introduced with Vista) points to the ''Public'' (pseudo) user profile directory "<code>C:\Users\Public</code>". ;{{anchor|ProgramFiles|ProgramFiles(x86)|ProgramW6432}}<code>%ProgramFiles%</code>, <code>%ProgramFiles(x86)%</code>, <code>%ProgramW6432%</code>: The <code>%ProgramFiles%</code> variable points to the ''Program Files'' directory, which stores all the installed programs of Windows and others. The default on English-language systems is "<code>C:\Program Files</code>". In 64-bit editions of Windows (XP, 2003, Vista), there are also <code>%ProgramFiles(x86)%</code>, which defaults to "<code>C:\Program Files (x86)</code>", and <code>%ProgramW6432%</code>, which defaults to "<code>C:\Program Files</code>". The <code>%ProgramFiles%</code> itself depends on whether the process requesting the environment variable is itself 32-bit or 64-bit (this is caused by [[WoW64|Windows-on-Windows 64-bit]] redirection<ref>{{cite web | url=https://msdn.microsoft.com/en-us/library/aa384274.aspx#environment-variables | title=WOW64 Implementation Details }}</ref>). ;{{anchor|CommonProgramFiles|CommonProgramFiles(x86)|CommonProgramW6432}}<code>%CommonProgramFiles%</code>, <code>%CommonProgramFiles(x86)%</code>, <code>%CommonProgramW6432%</code>: This variable points to the ''Common Files'' subdirectory of the ''Program Files'' directory. The default on English-language systems is "<code>C:\Program Files\Common Files</code>". In 64-bit editions of Windows (XP, 2003, Vista), there are also <code>%ProgramFiles(x86)%</code>, which defaults to "<code>C:\Program Files (x86)</code>", and <code>%ProgramW6432%</code>, which defaults to "<code>C:\Program Files</code>". The <code>%ProgramFiles%</code> itself depends on whether the process requesting the environment variable is itself 32-bit or 64-bit (this is caused by [[WoW64|Windows-on-Windows 64-bit]] redirection). ;{{anchor|SystemDrive}}<code>%OneDrive%</code>: The <code>%OneDrive%</code> variable is a special system-wide environment variable found on Windows NT and its derivatives. Its value is the path of where (if installed and setup) the Onedrive directory is located. The value of <code>%OneDrive%</code> is in most cases "<code>C:\Users\{Username}\OneDrive\</code>". ;{{anchor|SystemDrive}}<code>%SystemDrive%</code>: The <code>%SystemDrive%</code> variable is a special system-wide environment variable found on Windows NT and its derivatives. Its value is the drive upon which the system directory was placed. The value of <code>%SystemDrive%</code> is in most cases "<code>C:</code>". ;{{anchor|SystemRoot}}<code>%SystemRoot%</code>:The <code>%SystemRoot%</code> variable is a special system-wide environment variable found on the Windows NT family of operating systems. Its value is the location of the system directory, including the drive and path. The drive is the same as <code>%SystemDrive%</code> and the default path on a clean installation depends upon the version of the operating system. By default: :* [[Windows XP]] and newer versions use "<code>\WINDOWS</code>". :* [[Windows 2000]], [[Windows NT 4.0|NT 4.0]] and [[Windows NT 3.1|NT 3.1]] use "<code>\WINNT</code>". :* [[Windows NT 3.5]] and [[Windows NT 3.51|NT 3.51]] uses "<code>\WINNT35</code>". :* [[Windows NT 4.0 Terminal Server]] uses "<code>\WTSRV</code>". ;{{anchor|windir}}<code>%windir%</code><!-- all-lowercase at least under Windows 95β98/98SE and Windows XP -->:This variable points to the ''Windows'' directory. (On the Windows NT family of operating systems, it is identical to the <code>%SystemRoot%</code> variable). [[Windows 95]]β[[Windows 98|98]] and [[Windows ME]] are, by default, installed in "<code>C:\Windows</code>". For other versions of Windows, see the <code>%SystemRoot%</code> entry above. ''User management variables''{{citation needed|date=August 2014|reason=Is this an official name used in Microsoft literature? If not, we should not italicize it and use the official name instead.}} store information related to resources and settings owned by various [[user profile]]s 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. ;{{anchor|ALLUSERSPROFILE|PROGRAMDATA}}<code>%ALLUSERSPROFILE%</code><!-- all-uppercase at least under XP --> (<code>%PROGRAMDATA%</code> since Windows Vista): This 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. [[Shortcut (computing)|Shortcut]] links copied to the ''All Users''\' ''Start menu'' or ''Desktop'' directories will appear in every user's ''Start menu'' or ''[[Desktop metaphor|Desktop]]'', respectively. ;{{anchor|USERDOMAIN}}<code>%USERDOMAIN%</code><!-- all-uppercase at least under XP -->: The name of the ''[[Workgroup (computer networking)|Workgroup]]'' or ''[[Windows Server domain|Windows Domain]]'' to which the current user belongs. The related variable, <code>%LOGONSERVER%</code>, holds the [[hostname]] of the server that authenticated the current user's login 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 [[domain controller]] (a primary domain controller, or PDC, in Windows NT 4-based domains). ;{{anchor|USERPROFILE}}<code>%USERPROFILE%</code><!-- all-uppercase at least under XP -->: A special system-wide environment variable found on Windows NT and its derivatives. Its value is the location of the current user's profile directory, in which is found that user's HKCU registry hive (<code>NTUSER</code>). Users can also use the <code>%USERNAME%</code> variable to determine the active users login identification. ''Optional System variables''{{citation needed|date=August 2014|reason=Is this an official name used in Microsoft literature? If not, we should not italicize it and use the official name instead.}} are not explicitly specified by default but can be used to modify the default behavior of certain built-in console commands. These variables also do not need to be explicitly specified as command line arguments. ==== Default values ==== The following tables shows typical default values of certain environment variables under English versions of Windows as they can be retrieved under <code>[[CMD (Windows)|CMD]]</code>. (Some of these variables are also defined when running <code>COMMAND.COM</code> under Windows, but differ in certain important details: Under <code>COMMAND.COM</code>, the names of environment variable are always uppercased. Some, but not all variables contain short [[8.3 filename|8.3]] rather than [[long file name]]s. While some variables present in the <code>CMD</code> environment are missing, there are also some variables specific to the <code>COMMAND</code> environment.) {| class="wikitable" |- ! Variable ! Locale specific ! Windows XP (CMD) ! Windows Vista and later (CMD) |- | {{mono|%ALLUSERSPROFILE%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|C:\Documents and Settings\All Users}} | {{mono|C:\ProgramData}}<ref name="Schulz_2014_Ordner"/> |- | {{mono|%APPDATA%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|C:\Documents and Settings\%USERNAME%\Application Data}} | {{mono|C:\Users\%USERNAME%\AppData\Roaming}}<ref name="Schulz_2014_Ordner"/> |- | {{mono|%CommonProgramFiles%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|C:\Program Files\Common Files}} | {{mono|C:\Program Files\Common Files}}<ref name="Schulz_2014_Ordner"/> |- | {{mono|%CommonProgramFiles(x86)%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|C:\Program Files (x86)\Common Files}} ''(only in 64-bit version)'' | {{mono|C:\Program Files (x86)\Common Files}} ''(only in 64-bit version)''<ref name="Schulz_2014_Ordner"/> |- | {{mono|%CommonProgramW6432%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|%CommonProgramW6432%}} ''(not supported, not replaced by any value)'' | {{mono|C:\Program Files\Common Files}} ''(only in 64-bit version)''<ref name="Schulz_2014_Ordner"/> |- | {{mono|%COMPUTERNAME%}} | {{No}} | {computername} | {computername} |- | {{mono|%ComSpec%}} | {{No}} | {{mono|C:\Windows\System32\cmd.exe}} | {{mono|C:\Windows\System32\cmd.exe}} |- {{anchor|%HOMEDRIVE%}} | {{mono|%HOMEDRIVE%}}<ref name="Schulz_2014_Ordner"/> | {{No}} | C: | C:<ref name="Schulz_2014_Ordner"/> |- {{anchor|%HOMEPATH%}} | {{mono|%HOMEPATH%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|\Documents and Settings\%USERNAME%}} | {{mono|\Users\%USERNAME%}}<ref name="Schulz_2014_Ordner"/> |- | {{mono|%LOCALAPPDATA%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|%LOCALAPPDATA%}} ''(not supported, not replaced by any value)'' | {{mono|C:\Users\%USERNAME%\AppData\Local}}<ref name="Schulz_2014_Ordner"/> |- | {{mono|%LOGONSERVER%}} | {{No}} | {{mono|\\{domain_logon_server} }} | {{mono|\\{domain_logon_server} }} |- | {{mono|%PATH%}} | {{Yes}} | {{mono|C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;{plus program paths} }} | {{mono|C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;{plus program paths} }} |- | {{mono|%PATHEXT%}} | {{No}} | .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.WSF;.WSH | .com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.msc |- | {{mono|%ProgramData%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|%ProgramData%}} ''(not supported, not replaced by any value)'' | {{mono|%SystemDrive%\ProgramData}}<ref name="Schulz_2014_Ordner"/> |- | {{mono|%ProgramFiles%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|%SystemDrive%\Program Files}} | {{mono|%SystemDrive%\Program Files}}<ref name="Schulz_2014_Ordner"/> |- | {{mono|%ProgramFiles(x86)%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|%SystemDrive%\Program Files (x86)}} ''(only in 64-bit version)'' | {{mono|%SystemDrive%\Program Files (x86)}} ''(only in 64-bit version)''<ref name="Schulz_2014_Ordner"/> |- | {{mono|%ProgramW6432%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|%ProgramW6432%}} ''(not supported, not replaced by any value)'' | {{mono|%SystemDrive%\Program Files}} ''(only in 64-bit version)''<ref name="Schulz_2014_Ordner"/> |- | {{mono|%PROMPT%}} | {{No}} | Code for current command prompt format, usually {{code|$P$G}} | Code for current command prompt format, usually {{code|$P$G}} |- | {{mono|%PSModulePath%}} | | {{mono|%PSModulePath%}} ''(not supported, not replaced by any value)'' | {{mono|%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\}} |- | {{mono|%PUBLIC%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|%PUBLIC%}} ''(not supported, not replaced by any value)'' | {{mono|%SystemDrive%\Users\Public}}<ref name="Schulz_2014_Ordner"/> |- | {{mono|%SystemDrive%}}<ref name="Schulz_2014_Ordner"/> | {{No}} | C: | C:<ref name="Schulz_2014_Ordner"/> |- | {{mono|%SystemRoot%}}<ref name="Schulz_2014_Ordner"/> | {{No}} | The Windows directory, usually {{mono|C:\Windows}}, formerly {{mono|C:\WINNT}} | {{mono|%SystemDrive%\Windows}}<ref name="Schulz_2014_Ordner"/> |- | {{mono|%TEMP%}}<ref name="Schulz_2014_Ordner"/> and {{mono|%TMP%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|%SystemDrive%\Documents and Settings\%USERNAME%\Local Settings\Temp}} | {{mono|%SystemRoot%\TEMP}} (for system environment variables {{mono|%TMP%}} and {{mono|%TEMP%}}),<br/>{{mono|%USERPROFILE%\AppData\Local\Temp}}<ref name="Schulz_2014_Ordner"/> (for user environment variables {{mono|%TMP%}} and {{mono|%TEMP%}}) |- | {{mono|%USERDOMAIN%}} | {{No}} | {userdomain} | {userdomain} |- | {{mono|%USERNAME%}} | {{No}} | {USERNAME} | {USERNAME} |- | {{mono|%USERPROFILE%}}<ref name="Schulz_2014_Ordner"/> | {{Yes}} | {{mono|%SystemDrive%\Documents and Settings\%USERNAME% }} | {{mono|%SystemDrive%\Users\%USERNAME% }}<ref name="Schulz_2014_Ordner"/> |- | {{mono|%windir%}}<ref name="Schulz_2014_Ordner"/> | {{No}} | {{mono|%SystemDrive%\WINDOWS}} | {{mono|%SystemDrive%\Windows}}<ref name="Schulz_2014_Ordner"/> |} In this list, there is no environment variable that refers to the location of the user's ''My Documents'' directory, so there is no standard method for setting a program's home directory to be the ''My Documents'' directory.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)