China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-14 05:30
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » You can see a command's errorlevel by entering command /z View 1,211 Replies 10
Original Poster Posted 2004-02-02 00:00 ·  中国 广西 玉林 电信
初级用户
Credits 104
Posts 1
Joined 2004-01-22 00:00
22-year member
UID 15922
Gender Male
Status Offline
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.
Floor 2 Posted 2004-02-03 00:00 ·  加拿大 安大略省 多伦多
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
Everybody knows that...
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 3 Posted 2004-02-03 00:00 ·  中国 山西 运城 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
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?
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 4 Posted 2004-02-03 00:00 ·  中国 香港
管理员
★★★★
專業島民
Credits 4,869
Posts 1,633
Joined 2002-12-10 00:00
23-year member
UID 465
Gender Male
Status Offline
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%
我的網站:http://mw16.2ya.com/ 我的網誌: http://scrappedblog.blogspot.com/
~
我的Winamp正在播放的歌曲:
Floor 5 Posted 2004-02-03 00:00 ·  中国 山西 运城 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
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

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 6 Posted 2004-02-03 00:00 ·  加拿大 安大略省 多伦多
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
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.
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 7 Posted 2004-02-03 00:00 ·  中国 香港
管理员
★★★★
專業島民
Credits 4,869
Posts 1,633
Joined 2002-12-10 00:00
23-year member
UID 465
Gender Male
Status Offline
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.
我的網站:http://mw16.2ya.com/ 我的網誌: http://scrappedblog.blogspot.com/
~
我的Winamp正在播放的歌曲:
Floor 8 Posted 2004-02-04 00:00 ·  加拿大 安大略省 多伦多
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
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 ...
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 9 Posted 2004-02-04 00:00 ·  中国 山西 运城 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
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


※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 10 Posted 2005-10-01 10:49 ·  中国 台湾 新北市 中华电信
初级用户
★★
Credits 154
Posts 54
Joined 2005-09-25 01:53
20-year member
UID 42804
Status Offline
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
Floor 11 Posted 2005-10-01 15:54 ·  中国 重庆 渝中区 电信
银牌会员
★★★
Credits 2,165
Posts 730
Joined 2004-04-21 00:00
22-year member
UID 22966
Gender Male
Status Offline
Forum Jump: