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-01 12:39
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to add in a batch file to automatically enter "y" and execute in DOS? View 3,049 Replies 11
Original Poster Posted 2005-04-13 00:00 ·  中国 上海 东方有线
中级用户
★★
Credits 377
Posts 66
Joined 2005-04-04 00:00
21-year member
UID 37817
Gender Male
Status Offline
How to add a statement in a batch file that can automatically input "y" and perform the enter function under DOS?
I want to add in the batch file the function of automatically inputting "y" and performing the enter under DOS. What statement should be written? Please guide by the moderator and experts, thank you!
Floor 2 Posted 2005-04-13 00:00 ·  中国 广东 广州 教育网
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
如:echo y | del *.*

The example: echo y | del *.*
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 3 Posted 2005-04-13 00:00 ·  中国 上海 东方有线
中级用户
★★
Credits 377
Posts 66
Joined 2005-04-04 00:00
21-year member
UID 37817
Gender Male
Status Offline
Floor 2, I tried it and it didn't work! Also, your del *.* completely wiped out everything on my floppy disk!!! My problem is like this: I boot with a DOS disk and it shows a program's LOGO image and gives "yes" or "no" options. I want to add in a batch file to automatically input "y" and press Enter, so that it can automatically continue to start DOS for the next program. Is there any other good method?
Floor 4 Posted 2005-04-14 00:00 ·  中国 江苏 南京 电信
初级用户
Credits 133
Posts 10
Joined 2005-01-16 00:00
21-year member
UID 35376
Gender Male
Status Offline
The choice command: choice or choice /c:yn or you can also write such a command by yourself in C language. It should also be possible with assembly, I haven't tried it. There is a special function in C language that supports this practice for DOS/WINDOWS.
Floor 5 Posted 2005-04-14 00:00 ·  中国 上海 东方有线
中级用户
★★
Credits 377
Posts 66
Joined 2005-04-04 00:00
21-year member
UID 37817
Gender Male
Status Offline
I also thought of the method upstairs, but choice only gives a yes/no choice, and I still have to manually enter y, which doesn't achieve my goal of "automatically entering y under DOS and pressing Enter". Moreover, I tried it, and when the program reaches the line where it asks "y" or "no" for selection, it stops and no longer executes the choice command.
Floor 6 Posted 2005-04-14 00:00 ·  中国 湖南 长沙 电信
高级用户
★★
Credits 772
Posts 273
Joined 2004-10-23 00:00
21-year member
UID 32861
Gender Male
Status Offline
Haha~Funny~The LZ is so cute
http://www.msfans.net/bbs/
Floor 7 Posted 2005-04-14 00:00 ·  中国 江苏 南京 电信
初级用户
Credits 133
Posts 10
Joined 2005-01-16 00:00
21-year member
UID 35376
Gender Male
Status Offline
Hehe, that's the case. Automatically input y and press enter to execute, so there's no need for judgment at all, just execute directly. echo ?Ycommand^_^
Floor 8 Posted 2005-04-14 00:00 ·  中国 江苏 南京 电信
初级用户
Credits 133
Posts 10
Joined 2005-01-16 00:00
21-year member
UID 35376
Gender Male
Status Offline
Or as the second floor said, echo y | choice
Floor 9 Posted 2005-04-14 00:00 ·  中国 上海 东方有线
中级用户
★★
Credits 377
Posts 66
Joined 2005-04-04 00:00
21-year member
UID 37817
Gender Male
Status Offline
Dear fellow experts, let's still take a look at the conclusion of the站长 of DOS Home:
It cannot be achieved unless TSR is pre-loaded. Because during the execution of each program, an external intervention is necessary to interrupt. There are two types of interruptions: one is through input and output devices such as the keyboard, and the other is that the monitor program (resident program, English TSR) triggers under certain conditions.
----------------------------------------------
Ge Mingyang,站长 of DOS Home
http://doshome.com
I've given up, and I won't work on batch processing anymore, but I still want to thank all the experts for their enthusiastic guidance!
By the way, the method mentioned by the person upstairs, the command simply doesn't execute, because the program stops when the LOGO appears and "y" or "n" is displayed, waiting for you to manually input "y", and won't execute your command.

Floor 10 Posted 2005-04-14 00:00 ·  中国 广东 广州 海珠区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
The following is the statement from hxj on 2005-4-13 22:03:58:

On the 2nd floor, I tried and it didn't work! Also, your del *.* completely erased all the things on my floppy disk!!!
My problem is like this: After I boot with a DOS disk, a program's LOGO image is displayed and it gives "yes" or "no" options. I want to add in the batch file to automatically input "y" and press enter, so that it can automatically continue to start DOS for the following program. I wonder if there are any other good methods?


Hehe, since you didn't make the problem clear in advance, I just used del as an example to demonstrate, and didn't ask you to copy the whole sentence exactly.
The conclusion of DOS webmaster Ge Yangming is reasonable, but it's not necessary to use TSR. The Kpush small program on the MSDOS 7.1 boot disk is a very good thing that can set the keyboard buffer. Making good use of it can achieve the purpose of the original poster. For example: Before executing the statement of selecting Y or N in the batch processing, run kpush y first.
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 11 Posted 2005-04-15 00:00 ·  中国 上海 杨浦区 电信
初级用户
Credits 120
Posts 5
Joined 2005-04-12 00:00
21-year member
UID 38092
Gender Male
Status Offline
You can use input redirection. First, edit a text file with the content: Yenter. Then add "< text file name" after running your batch file. For example: format a: < zzz.txt
Floor 12 Posted 2005-04-19 00:00 ·  中国 江苏 南京 电信
初级用户
Credits 133
Posts 10
Joined 2005-01-16 00:00
21-year member
UID 35376
Gender Male
Status Offline
The following is the speech of hxj on April 14, 2005, 20:23:44:

Dear experts, let's still take a look at the conclusion of the webmaster of DOS Home:
Unless TSR is loaded in advance, it cannot be achieved. Because during the execution of each program, there must be external intervention to interrupt. There are two types of interrupts. One is using input and output devices such as the keyboard. The other is that the monitoring program (resident program, English TSR) triggers under certain conditions.
----------------------------------------------
Ge Mingyang, Webmaster of DOS Home
http://doshome.com
I'm disheartened and won't work on batch processing anymore. But I still want to thank all the enthusiastic guides of you!
By the way, the method of the above-mentioned building, the command does not execute at all. Because the program stops and waits for you to manually input "y" when it appears LOGO and "y" or "n". No longer execute your command.



I don't know if the author of the quoted post has tested it on his own machine. If not, don't talk casually!
Forum Jump: