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-06-23 00:22
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Please tell me the calling method of COMMAND in the batch file? View 1,523 Replies 6
Original Poster Posted 2005-08-19 00:14 ·  中国 四川 攀枝花 电信
初级用户
Credits 67
Posts 12
Joined 2005-08-15 18:25
20-year member
UID 41681
Status Offline
Floor 2 Posted 2005-08-19 15:07 ·  中国 广东 广州 白云区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
Running COMMAND will directly load a new COMMAND and prompt the DOS version number and command prompt. You can try running COMMAND, then run a batch script that needs to automatically respond to "Abort, Retry, Fail", and finally exit, then the new COMMAND will automatically exit and return to the original state without automatic response.

COMMAND /F
F.BAT
EXIT
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 3 Posted 2005-08-19 16:30 ·  中国 山西 运城 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re icevan:

The command /f requires the /c switch to call the batch program or internal and external commands for which you need to ignore error prompts; of course, the problem cannot be simply solved by using command /f. You can refer to the following link:

{12892}Discussion about "Hard Disk Killer" Batch Program
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 4 Posted 2005-08-20 21:41 ·  中国 四川 攀枝花 电信
初级用户
Credits 67
Posts 12
Joined 2005-08-15 18:25
20-year member
UID 41681
Status Offline
Thanks to the two upstairs for helping.

Now there is a new problem:
Calling the F.BAT file with COMMAND/F/C can automatically respond to "ABORT,RETRY,FAIL" and then exit this new shell (I don't know if it's correct to call it a shell).
But the variable romcd generated in the new shell also disappears. How can I add the variables in the new environment to the original environment? The new environment can inherit the variables in the old environment.

I tried it myself~ Found a stupid way to add the variables of the new environment to the old environment, modified F.BAT to:

if exist %cdrom1%\tools\vc.ini goto cd1 (VC.INI is a file in the CD)
if exist %cdrom2%\tools\vc.ini goto cd2

:cd1
set romcd=%cdrom1%
echo set cd-rom=%romcd%>scd.bat
goto end

:cd2
Then call the SCD.BAT file. Please let me know if anyone has a good method?
PS: <Discussion about "Hard Disk Killer" batch processing> I don't understand because of insufficient ability~~
Another PS: When COMMAND/F/C F.BAT is executed, it automatically responds to the selection, but the prompt of ABORT,RETRY,FAIL still appears on the screen~ How can I make it not display?

[ Last edited by icevan on 2005-8-20 at 22:49 ]
Floor 5 Posted 2005-08-20 22:14 ·  中国 广东 广州 白云区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
Originally posted by icevan at 2005-8-20 21:41:
But the variable romcd generated in the new shell also disappears. How can I add the variables in the new environment to the original environment? The new environment can inherit the variables in the old environment.


Hehe, the owner's question has caught my attention. I never expected such a situation.

As a command interpreter, Command.com runs on the DOS platform built with IO.SYS and MSDOS.SYS. Command is like Explorer.exe in Windows, so let's姑且call it the shell of DOS.
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 6 Posted 2005-08-20 22:43 ·  中国 山西 临汾 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re icevan:

The command is fully called "shell". You can see from the shell command in config.sys used to load the command that the kernel at this time should be io.sys (in the old version, there is also msdos.sys). They provide many interrupt services and device ports for frequent calls by the "command interpreter".

As for the return of environment variables, you can first save the variables in the sub-shell (new shell) to the batch program, for example, echo set var=%var%>_return.bat, and then extract it after returning to the parent shell (old shell). For example, call _return.bat.

In addition, if you find that discussion too abstract, you can refer to this post:

{8804}Password program that can customize password (batch processing)

[ Last edited by willsort on 2005-8-20 at 22:45 ]
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 7 Posted 2005-08-20 22:52 ·  中国 四川 攀枝花 电信
初级用户
Credits 67
Posts 12
Joined 2005-08-15 18:25
20-year member
UID 41681
Status Offline
After reading <Discussion about "Hard Disk Killer" Batch Processing> again, I solved the problem of shielding the ABORT, RETRY, FAIL prompts. But there is another problem~
"In XP and other NT - like command lines, ctty is canceled. In such an environment, you can only redirect error messages through 2> nul. "
How to do double redirection to NUL?

[ Last edited by icevan on 2005-8-21 at 16:22 ]
Forum Jump: