Actions

Pseudo-environment variables::Environment variable

::concepts

Variable::anchor    Command::windows    DR-DOS::under    COMMAND::current    Ordner::schulz    System::returns

Pseudo-environment variables

{{safesubst:#invoke:anchor|main}}DOS

{{safesubst:#invoke:anchor|main}}Besides true environment variables, which are statically stored in the environment until changed or deleted, a number of pseudo-environment variables exist for batch processing.

The so-called replacement parameters or replaceable parameters (Microsoft / IBM terminology) aka replacement variables (Digital Research / Novell / Caldera terminology)<ref name="Caldera_1998_USER"/> or batch file parameters (JP Software terminology)<ref name="4DOS_8.00_HELP"/> %1..%9 and %0 can be used to retrieve the calling parameters of a batchjob, see SHIFT. In batchjobs, they can be retrieved just like environment variables, but are not actually stored in the environment.

{{safesubst:#invoke:anchor|main}} Some command-line processors (like DR-DOS COMMAND.COM,<ref name="Caldera_1998_USER"/> Multiuser DOS MDOS.COM/TMP.EXE, JP Software 4DOS, 4OS2, 4NT, Take Command and Windows CMD.EXE) support a type of pseudo-environment variables named system information variables (Novell / Caldera terminology)<ref name="Caldera_1998_USER"/> or internal variables (JP Software terminology),<ref name="4DOS_8.00_HELP"/> which can be used to retrieve various possibly dynamic, but read-only information about the running system in batch jobs. The returned values represent the status of the system in the moment these variables are queried; that is, reading them multiple times in a row may return different values even within the same command; querying them has no direct effect on the system. Since they are not stored in the environment, they are not listed by SET and do not exist for external programs to retrieve. If a true environment variable of the same name is defined, it takes precedence over the corresponding variable until the environment variable is deleted again. They are not case-sensitive. While almost all such variables are prefixed with an underscore ("_") by 4DOS etc. by convention (f.e. %_SECOND%),<ref name="4DOS_8.00_HELP"/> they are not under DR-DOS COMMAND.COM (f.e. %OS_VERSION%).

{{safesubst:#invoke:anchor|main}}In addition, 4DOS, 4OS2, 4NT, and Take Command also support so called variable functions,<ref name="4DOS_8.00_HELP"/> including user-definable ones. They work just like internal variables, but can take optional parameters (f.e. %@EVAL[]%) and may even change the system status depending on their function.

System information variables supported by DR-DOS COMMAND.COM:

{{safesubst
#invoke:anchor|main}}%AM_PM%: This pseudo-variable returns the ante- or post-midday status of the current time. The returned string depends on the locale-specific version of DR-DOS, f.e. "am" or "pm" in the English version. It resembles an identically named identifier variable in Novell NetWare login scripts.
{{safesubst
#invoke:anchor|main}}%DAY%: This pseudo-variable returns the days of the current date in a 2-digit format with leading zeros, f.e. "01".."31". See also the similar pseudo-variable %_DAY%. It resembles an identically named identifier variable in Novell NetWare login scripts.
{{safesubst
#invoke:anchor|main}}%DAY_OF_WEEK%: This pseudo-variable returns the day name of the week in a 3-character format. The returned string depends on the locale-specific version of DR-DOS, f.e. "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", or "Sat" in the English version. It resembles an identically named identifier variable in Novell NetWare login scripts.
{{safesubst
#invoke:anchor|main}}%ERRORLEVEL%: In COMMAND.COM of DR-DOS 7.02 and higher, this pseudo-variable returns the last error level returned by an external program or the RETURN command, f.e. "0".."255". See also the identically named pseudo-variable %ERRORLEVEL% under Windows and the IF ERRORLEVEL command.
{{safesubst
#invoke:anchor|main}}%ERRORLVL%: In Multiuser DOS as well as in DR-DOS 7.02 and higher, this pseudo-variable returns the last error level in a 3-digit format with leading zeros, f.e. "000".."255". See also the related pseudo-variable %ERRORLEVEL% under DR-DOS and the IF ERRORLEVEL command.
{{safesubst
#invoke:anchor|main}}%GREETING_TIME%: This pseudo-variable returns the 3-level day greeting time. The returned string depends on the locale-specific version of DR-DOS, f.e. "morning", "afternoon", or "evening" in the English version. It resembles an identically named identifier variable in Novell NetWare login scripts.
{{safesubst
#invoke:anchor|main}}%HOUR%: This pseudo-variable returns the hours of the current time in 12-hour format without leading zeros, f.e. "1".."12". It resembles an identically named identifier variable in Novell NetWare login scripts.
{{safesubst
#invoke:anchor|main}}%HOUR24%: This pseudo-variable returns the hours of the current time in 24-hour format in a 2-digit format with leading zeros, f.e. "00".."23". It resembles an identically named identifier variable in Novell NetWare login scripts. See also the similar pseudo-variable %_HOUR%.
{{safesubst
#invoke:anchor|main}}%MINUTE%: This pseudo-variable returns the minutes of the current time in a 2-digit format with leading zeros, f.e "00".."59". It resembles an identically named identifier variable in Novell NetWare login scripts. See also the similar pseudo-variable %_MINUTE%.
{{safesubst
#invoke:anchor|main}}%MONTH%: This pseudo-variable returns the months of the current date in a 2-digit format with leading zeros, f.e. "01".."12". It resembles an identically named identifier variable in Novell NetWare login scripts. See also the similar pseudo-variable %_MONTH%.
{{safesubst
#invoke:anchor|main}}%MONTH_NAME%: This pseudo-variable returns the month name of the current date. The returned string depends on the locale-specific version of DR-DOS, f.e. "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", or "December" in the English version. It resembles an identically named identifier variable in Novell NetWare login scripts.
{{safesubst
#invoke:anchor|main}}%NDAY_OF_WEEK%: This pseudo-variable returns the number of day of the current week, f.e. "1".."7" (with "1" for Sunday). It resembles an identically named identifier variable in Novell NetWare login scripts.
{{safesubst
#invoke:anchor|main}}%OS_VERSION%: This pseudo-variable returns the version of the operating system depending on the current setting of the environment variable %VER%. If %VER% is not defined, %OS_VERSION% returns "off". It resembles an identically named identifier variable in Novell NetWare login scripts, which may return versions also for non-DR-DOS versions of DOS.
{{safesubst
#invoke:anchor|main}}%SECOND%: This pseudo-variable returns the seconds of the current time in a 2-digit format with leading zeros, f.e. "00".."59". It resembles an identically named identifier variable in Novell NetWare login scripts. See also the similar pseudo-variable %_SECOND%.
{{safesubst
#invoke:anchor|main}}%SHORT_YEAR%: This pseudo-variable returns the year of the current date in a 2-digit format with leading zeros, f.e. "93".."99", "00".."92". It resembles an identically named identifier variable in Novell NetWare login scripts.
{{safesubst
#invoke:anchor|main}}%YEAR% and %_YEAR%: Supported since Novell DOS 7, the %YEAR% pseudo-variable returns the year of the current date in a 4-digit format, f.e. "1980".."2099". It resembles an identically named identifier variable in Novell NetWare login scripts. DR-DOS 7.02 and higher added %_YEAR% for compatibility with 4DOS, returning the same value.<ref name="4DOS_8.00_HELP"/>
{{safesubst
#invoke:anchor|main}}%/%: In COMMAND.COM of DR-DOS 7.02 and higher, this pseudo-variable returns the current SwitChar setting of the system, either "/" (DOS style) or "-" (Unix style).<ref name="Caldera_1998_DELTREE101"/><ref name="Caldera_1998_NEW703"/> See also the related CONFIG.SYS directive SWITCHAR and the environment variable %SWITCHAR%.
{{safesubst
#invoke:anchor|main}}%_CODEPAGE%: This pseudo-variable returns the systems' current code page ("1".."65533"), f.e. "437", "850", "858". This variable was originally introduced by 4DOS,<ref name="4DOS_8.00_HELP"/> but also became available with COMMAND.COM since DR-DOS 7.02. See also the CHCP command.
{{safesubst
#invoke:anchor|main}}%_COLUMNS%: This pseudo-variable returns the current number of screen columns depending on the display mode, f.e. "40", "80", "132", etc. This variable was originally introduced by 4DOS,<ref name="4DOS_8.00_HELP"/> but also became available with COMMAND.COM since DR-DOS 7.02. See also a similar environment variable %$WIDTH% under DOS Plus.
{{safesubst
#invoke:anchor|main}}%_COUNTRY%: This pseudo-variable returns the systems' current country code ("1".."65534"), f.e. "1" for USA, "44" for UK, "49" for Germany, "20049" with ISO 8601, "21049" with ISO 8601 and Euro support. This variable was originally introduced by 4DOS,<ref name="4DOS_8.00_HELP"/> but also became available with COMMAND.COM since DR-DOS 7.02. See also the CONFIG.SYS directive COUNTRY.
{{safesubst
#invoke:anchor|main}}%_DAY%: This pseudo-variable returns the days of the current date without leading zeros, f.e. "1".."31". This variable was originally introduced by 4DOS,<ref name="4DOS_8.00_HELP"/> but also became available with COMMAND.COM since DR-DOS 7.02. See also the similar pseudo-variable %DAY%.
{{safesubst
#invoke:anchor|main}}%_HOUR%: This pseudo-variable returns the hours of the current time in 24-hour format without leading zeros, f.e. "0".."23". This variable was originally introduced by 4DOS,<ref name="4DOS_8.00_HELP"/> but also became available with COMMAND.COM since DR-DOS 7.02. See also the similar pseudo-variable %HOUR24%.
{{safesubst
#invoke:anchor|main}}%_MINUTE%: This pseudo-variable returns the minutes of the current time without leading zeros, f.e "0".."59". This variable was originally introduced by 4DOS,<ref name="4DOS_8.00_HELP"/> but also became available with COMMAND.COM since DR-DOS 7.02. See also the similar pseudo-variable %MINUTE%.
{{safesubst
#invoke:anchor|main}}%_MONTH%: This pseudo-variable returns the months of the current date without leading zeros, f.e. "1".."12". This variable was originally introduced by 4DOS,<ref name="4DOS_8.00_HELP"/> but also became available with COMMAND.COM since DR-DOS 7.02. See also the similar pseudo-variable %MONTH%.
{{safesubst
#invoke:anchor|main}}%_ROWS%: This pseudo-variable returns the current number of screen rows depending on the display mode, f.e. "25", "43", "50", etc. This variable was originally introduced by 4DOS,<ref name="4DOS_8.00_HELP"/> but also became available with COMMAND.COM since DR-DOS 7.02. See a similar environment variable %$LENGTH% under DOS Plus.
{{safesubst
#invoke:anchor|main}}%_SECOND%: This pseudo-variable returns the seconds of the current time without leading zeros, f.e. "0".."59". This variable was originally introduced by 4DOS,<ref name="4DOS_8.00_HELP"/> but also became available with COMMAND.COM since DR-DOS 7.02. See also the similar pseudo-variable %SECOND%.

System information variables supported by DR-DOS COMMAND.COM with networking loaded:

{{safesubst
#invoke:anchor|main}}%LOGIN_NAME%: This pseudo-variable returns the user name. This always worked with NETX, but it will also work with Personal NetWare's ODI/VLM if the current drive is a PNW-mapped drive (otherwise an empty string is returned). See also the similarly named environment variable %LOGINNAME%.
{{safesubst
#invoke:anchor|main}}%P_STATION%: This pseudo-variable returns the physical station number in a format "????????????". The value depends on the MAC address of the network adapter, but can be overridden. It resembles an identically named identifier variable in Novell NetWare login scripts.
{{safesubst
#invoke:anchor|main}}%STATION%: This pseudo-variable returns the logical station number starting with "1" for the first client. The numbers are assigned by the file server and remain static for as long as the IPX connection remains established. It resembles an identically named identifier variable in Novell NetWare login scripts.
{{safesubst
#invoke:anchor|main}}%FULL_NAME%: This pseudo-variable returns the full name of the logged in user, if available. It resembles an identically named identifier variable in Novell NetWare login scripts. See also the related pseudo-variable %LOGIN_NAME%.

{{safesubst:#invoke:anchor|main}}Windows

Dynamic environment variables (also named internal variables or system information variables under DOS) are pseudo-environment variables supported by CMD 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 batchjobs and at the prompt, they are not stored in the environment. Consequently, they are neither listed by SET nor do they exist for external programs to read. They are not case-sensitive.

Indirectly, they are also supported under Windows' COMMAND.COM, which has been modified to internally call CMD.EXE to execute the commands.

{{safesubst
#invoke:anchor|main}}%CD%: This pseudo-variable expands to the current directory equivalent to the output of the command CD when called without arguments. While a long filename can be returned under CMD.EXE depending on the current directory, the fact that the current directory will always be in 8.3 format under COMMAND.COM will cause it to return a short filename under COMMAND.COM, even when COMMAND internally calls CMD.
{{safesubst
#invoke:anchor|main}}%CMDCMDLINE%: This pseudo-variable expands to the original startup parameters of CMD.EXE, f.e. "C:\Windows\system32\cmd.exe". Under Windows' COMMAND.COM, this may return something like "C:\Windows\system32\cmd.exe /c ..." due to the fact that COMMAND.COM calls CMD.EXE internally.
{{safesubst
#invoke:anchor|main}}%CMDEXTVERSION%: This pseudo-variable expands to the version of the command-line extensions of CMD.EXE, if enabled (e.g. "1" under Windows NT, "2" under Windows 2000 and Windows XP).
{{safesubst
#invoke:anchor|main}}%DATE%: This pseudo-variable expands to the current date. The date is displayed according to the current user's date format preferences.
{{safesubst
#invoke:anchor|main}}%ERRORLEVEL%: This pseudo-variable expands to the last set error level, a value between "0" and "255" (without leading zeros). External commands and some internal commands set error levels upon execution. See also the identically named pseudo-variable %ERRORLEVEL% under DR-DOS and the IF ERRORLEVEL command.
{{safesubst
#invoke:anchor|main}}%RANDOM%: This pseudo-variable returns a random number between "0" and "32767".
{{safesubst
#invoke:anchor|main}}%TIME%: This pseudo-variable returns the current time. The time is displayed according to the current user's time format preferences. If the %TIME% and %DATE% 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.

Environment variable sections
Intro   Details    Use and display    Assignment    True environment variables    Pseudo-environment variables   Critics   See also   References   External links   

Pseudo-environment variables
PREVIOUS: IntroNEXT: Details
<<>>