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-13 23:46
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » [Help] Questions about return codes and parameters in batch files. View 1,076 Replies 0
Original Poster Posted 2006-04-14 15:23 ·  中国 上海 浦东新区 电信
初级用户
Credits 26
Posts 9
Joined 2006-03-16 16:57
20-year member
UID 52194
Status Offline
I’ve read a lot of batch file tutorials, but the explanations of return codes and parameters in batch files are never very detailed.
But if you want to make a fairly complete batch file, these two areas need to be used a lot.

For example, I want to use a CD to do automatic Ghost system recovery. I hope it can boot from the CD automatically and use the image file on the CD to overwrite drive C:.
The autoexec.bat file looks like this

MSCDEX.EXE /D:IDECE001 /L:Z
Ghost -clone,mode=load,src=z:\bac.gho,dst=1:1 -sure -rb

Now I want there to be a prompt after booting from the CD: if needed, press "1"; if not, press "2" to exit.

So I need a return code for the judgment.
How should autoexec.bat on the CD be set up?

And a lot of batch files use parameters, but there have never been very detailed tutorials on how parameters are used.
For example, the batch file below,

echo.
message /b 15 1 %msg%
echo *** %msg% ***>> c:\diag\proc.log
getrtime >> c:\diag\proc.log

How is %msg% used here? Could an expert give me some pointers?


I hope an expert can give a simple explanation of these two aspects. I would be extremely grateful.
Forum Jump: