中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-14 04:45
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS学习入门 & 精彩文章 (教学室) » You can see a command's errorlevel by entering command /z
Printable Version  1,209 / 10
Floor1 polynominal Posted 2004-02-02 00:00
初级用户 Posts 1 Credits 104
Has anyone written about this? :-)
When writing a batch file, if a lot of errorlevels are unclear, what do you do?
Enter command /z, and then the errorlevel of external commands you run later
can be seen.
Floor2 Wengier Posted 2004-02-03 00:00
系统支持 Posts 10,521 Credits 27,736
Everybody knows that...
Floor3 willsort Posted 2004-02-03 00:00
元老会员 Posts 1,512 Credits 4,432
Re polynominal:

Unfortunately DOS 6.x and below do not support it. Right now I am working on a high-efficiency BATCH for obtaining ERRORLEVEL. Without the problem I mentioned, it can be finished very quickly.

Re Wengier:

Isn't that a bit too absolute?
Floor4 Roy Posted 2004-02-03 00:00
管理员 Posts 1,633 Credits 4,869
The following is quoted from willsort's post on 2004-2-3 13:40:21:
Re polynominal:

    Unfortunately DOS 6.x and below do not support it. Right now I am working on a high-efficiency BATCH for obtaining ERRORLEVEL. Without the problem I mentioned, it can be finished very quickly.
This is it:
:: Author: Leonardo Pignataro (secret_doom@hotmail.com)
:: Trace errorlevel
@echo off
for %%? in (0 1 2) do if errorlevel=%%?00 set D1=%%?
for %%? in (0 1 2 3 4 5 6 7 8 9) do if errorlevel=%D1%%%?0 set D2=%%?
for %%? in (0 1 2 3 4 5 6 7 8 9) do if errorlevel=%D1%%D2%%%? set D3=%%?
set err=%D1%%D2%%D3%
for %%? in (D1 D2 D3) do set %%?=
echo %err%
Floor5 willsort Posted 2004-02-03 00:00
元老会员 Posts 1,512 Credits 4,432
Re roy:

Nice idea, it can serve as a reference for me to finish the next post. Just one thing: could you please not use = after IF ERRORLEVEL? It deepens misunderstanding.

http://model.chinajewelry.net/dos/dosbbs/dispbbs.asp?boardID=6&ID=9358

Floor6 Wengier Posted 2004-02-03 00:00
系统支持 Posts 10,521 Credits 27,736
willsort:

As for COMMAND /Z, because I had introduced it on the website before as an undocumented DOS usage, that is why I thought everyone should already know it.

Actually ERR2ENV may be easier to use.

As for DOS 6.x and below, then it has no real meaning. Those old DOS versions no longer have much practical value, and of course they do not support these new features either.
Floor7 Roy Posted 2004-02-03 00:00
管理员 Posts 1,633 Credits 4,869
The following is quoted from willsort's post on 2004-2-3 20:29:42:
Reroy:

Nice idea, it can serve as a reference for me to finish the next post. Just one thing: could you please not use = after IFERRORLEVEL? It deepens misunderstanding.

http://model.chinajewelry.net/dos/dosbbs/dispbbs.asp?boardID=6&ID=9358
ERRORLEVEL is a variable, just like %COMSPEC%, so "=" can be used.

What's more, the one who's wrong isn't me, it's Leonardo Pignataro.
Floor8 Wengier Posted 2004-02-04 00:00
系统支持 Posts 10,521 Credits 27,736
Roy: That's not right. This isn't under the WinNT/2K/XP "command prompt interface." Under pure DOS, ERRORLEVEL is not a variable, but a special usage of IF, namely: IF ERRORLEVEL ...
Floor9 willsort Posted 2004-02-04 00:00
元老会员 Posts 1,512 Credits 4,432
Re Wengier:

People nowadays collect a lot of valuable materials, but study little of them. Many people only come to the forum to ask when they actually need something. So the spread of information does not lie in whether it is public, but in whether the audience has the desire to learn about it.

Re Roy:

What Wengier said is quite right: errorlevel is used as an if command branch. Even under 98 and xp I have never seen this environment variable. And if this ERRORLEVEL were an environment variable, then this program itself would lose its meaning, because the purpose of the program is to assign the ERRORLEVEL value to an environment variable. Even if we assume Leonardo Pig was using it as a variable, then he should have used ==; otherwise it would be a syntax error. So here we can be sure he was using it as a command branch.

And when used as a command branch, the relationship between ERRORLEVEL and value should be greater than or equal to, not equal, so that is why I said = is somewhat misleading. Then why can = still be used? Because ERRORLEVEL and value are originally separated by a space, and the DOS command line ignores a single = when parsing. This is the same as ; and a space. If you don't believe it, you can do a test.

::test.bat
echo First:%1
echo Second:%2

c:\test 111 222
c:\test 111;222
c:\test 111=222

Also, there are many characters in the DOS command line that get special interpretation. Everyone can test more of them. Redirect symbols are too familiar, so I'll skip them


Floor10 dosfroum Posted 2005-10-01 10:49
初级用户 Posts 54 Credits 154
Why is there no response when I type it under Windows 2000?
Under commnad or under cmd
typing COMMAND /Z just jumps to the next line
Floor11 bush Posted 2005-10-01 15:54
银牌会员 Posts 730 Credits 2,165
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023