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-PSEUDOENV}}Windows === ''Dynamic environment variables'' (also named ''internal variables'' or ''system information variables'' under DOS) are pseudo-environment variables supported by <code>[[CMD (Windows)|CMD.EXE]]</code> when command-line extensions are enabled, and they expand to various discrete values whenever queried, that is, their values can change when queried multiple times even within the same command. While they can be used in batch jobs and at the prompt, they are not stored in the environment. Consequently, they are neither listed by <code>SET</code> nor do they exist for external programs to read. They are not case-sensitive. Indirectly, they are also supported under Windows' <code>COMMAND.COM</code>, which has been modified to internally call <code>CMD.EXE</code> to execute the commands.<!-- see ECHO %CMDCMDLINE% under COMMAND.COM --> ;{{anchor|CD}}<code>%CD%</code>: This pseudo-variable expands to the current directory equivalent to the output of the command <code>[[cd (command)|CD]]</code> when called without arguments. While a long filename can be returned under <code>CMD.EXE</code> depending on the current directory, the fact that the current directory will always be in [[8.3 filename|8.3]] format under <code>COMMAND.COM</code> will cause it to return a short filename under <code>COMMAND.COM</code>, even when <code>COMMAND</code> internally calls <code>CMD</code>. ;{{anchor|CMDCMDLINE}}<code>%CMDCMDLINE%</code>: This pseudo-variable expands to the original startup parameters of <code>[[CMD.EXE]]</code>, f.e. "<code>C:\Windows\system32\cmd.exe</code>". Under Windows' <code>COMMAND.COM</code>, this may return something like "<code>C:\Windows\system32\cmd.exe /c ...</code>" due to the fact that <code>COMMAND.COM</code> calls <code>CMD.EXE</code> internally. ;{{anchor|CMDEXTVERSION}}<code>%CMDEXTVERSION%</code>: This pseudo-variable expands to the version of the command-line extensions of <code>[[CMD.EXE]]</code>, if enabled (e.g. "<code>1</code>" under [[Windows NT]], "<code>2</code>" under [[Windows 2000]] and [[Windows XP]]). ;{{anchor|DATE}}<code>%DATE%</code>: This pseudo-variable expands to the current date. The date is displayed according to the current user's [[Calendar date|date format]] preferences. ;{{anchor|ERRORLEVEL}}<code>%ERRORLEVEL%</code>: This pseudo-variable expands to the last set error level, a value between "<code>0</code>" and "<code>255</code>" (without leading zeros).<ref name="Paul_1997_BATTIPS"/><ref name="Allen_2005"/><ref name="FD_2003_Errorlevel"/> External commands and some internal commands set error levels upon execution. See also the identically named pseudo-variable <code>[[#%ERRORLEVEL%|%ERRORLEVEL%]]</code> under DR-DOS and the <code>[[IF ERRORLEVEL (Windows command)|IF ERRORLEVEL]]</code> command. ;{{anchor|HIGHESTNUMANODENUMBER}}<code>%HIGHESTNUMANODENUMBER%</code>: This pseudo-variable returns the number of the highest [[Non-uniform memory access|NUMA]] node. ;{{anchor|RANDOM}}<code>%RANDOM%</code>: This pseudo-variable returns a random number between "<code>0</code>" and "<code>32767</code>". ;{{anchor|TIME}}<code>%TIME%</code>: This pseudo-variable returns the current time. The time is displayed according to the current user's time format preferences. If the <code>%TIME%</code> and <code>[[#DATE|%DATE%]]</code> variables are both used, it is important to read them both in this particular order in rapid succession in order to avoid midnight-rollover problems.
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)