I am using Windows XP SP3.
If I open a Command Prompt window, and type
ECHO %DATE%
I get:
14-08-2018
like I should.
But If I exit Windows and boot my computer from a bootable USB Flash Drive that has DOS
(real DOS, not the command prompt inside Windows),
and enter the same command,
then %DATE%
seems to be empty.
The command
ECHO %DATE%
replies
ECHO is On
Because it thinks that I just wrote ECHO
,
since the value returned from %DATE%
is "".
I tried it with 2 different DOS Versions..
Win98's DOS, and WinME's DOS.
(2 different USB Flash Drives)
Does anyone know why I cannot get the Date in real DOS,
while I can successfully get it when I am in Windows' command prompt?
%ERRORLEVEL%
is not a variable in DOS
%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 theIF ERRORLEVEL
conditional command.
As you can see, it only exists in DR-DOS 7.02 onwards and Windows. DR-DOS also has %ERRORLVL%
OTOH %DATE%
only exists on Windows
%DATE%
This pseudo-variable expands to the current date. The date is displayed according to the current user's date format preferences.
They're new features of cmd.exe which requires command extension to be enabled
If Command Extensions are disabled, the following dynamic variables will be not accessible:
%CD% %DATE% %TIME% %RANDOM% %ERRORLEVEL% %CMDEXTVERSION% %CMDCMDLINE% %HIGHESTNUMANODENUMBER%
Therefore if you turn off command extension for DOS compatibility you'll also lose those variables on Windows cmd.exe