本文介绍了为什么这些DOS变量为空? (例如,%DATE%,%ERRORLEVEL%)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows XP SP3。

I am using Windows XP SP3.

如果我打开命令提示符窗口,然后键入

If I open a Command Prompt window, and type

ECHO %DATE%

我得到:

14-08-2018



like I should.

但是如果我退出Windows并从具有DOS的可启动USB闪存驱动器启动计算机,则为

(实际DOS ,而不是Windows中的命令提示符),

并输入相同的命令,

然后%DATE%似乎为空

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.

命令

ECHO %DATE%

回复

ECHO is On

因为它认为我刚刚写了 ECHO

,因为从%DATE%返回的值是。

Because it thinks that I just wrote ECHO,
since the value returned from %DATE% is "".

我尝试了2种不同的DOS版本。.

Win98的DOS和WinME的DOS。

(2个不同的USB闪存驱动器)

I tried it with 2 different DOS Versions..
Win98's DOS, and WinME's DOS.
(2 different USB Flash Drives)

有人知道我为什么吗无法在实际的DOS中获取日期,

,但是当我在Windows的命令提示符下可以成功获取日期时?

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%在DOS中不是变量

如您所见,它仅存在于DR-DOS 7.02及更高版本中。 DR-DOS还只有%ERRORLVL%

As you can see, it only exists in DR-DOS 7.02 onwards and Windows. DR-DOS also has %ERRORLVL%

OTOH %DATE% Windows上存在

OTOH %DATE% only exists on Windows

它们是cmd.exe的新功能需要启用

They're new features of cmd.exe which requires command extension to be enabled

%CD% %DATE% %TIME% %RANDOM% %ERRORLEVEL% %CMDEXTVERSION% %CMDCMDLINE% %HIGHESTNUMANODENUMBER%

因此,如果您关闭命令扩展以实现DOS兼容性,那么您在Windows cmd.exe上也会丢失这些变量。

Therefore if you turn off command extension for DOS compatibility you'll also lose those variables on Windows cmd.exe

这篇关于为什么这些DOS变量为空? (例如,%DATE%,%ERRORLEVEL%)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 18:01