![]() |
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-09-23 14:09 |
47,812 topics / 349,917 posts / today 0 new / 48,273 members |
| DOS批处理 & 脚本技术(批处理室) » [Help] How to add in a batch file to automatically enter "y" and execute in DOS? |
| Printable Version 3,217 / 11 |
| Floor1 hxj | Posted 2005-04-13 00:00 |
| 中级用户 Posts 66 Credits 377 | |
|
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! |
|
| Floor2 JonePeng | Posted 2005-04-13 00:00 |
| 金牌会员 Posts 1,883 Credits 4,562 From 广东广州 | |
|
如:echo y | del *.*
The example: echo y | del *.* |
|
| Floor3 hxj | Posted 2005-04-13 00:00 |
| 中级用户 Posts 66 Credits 377 | |
|
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?
|
|
| Floor4 siyuer | Posted 2005-04-14 00:00 |
| 初级用户 Posts 10 Credits 133 | |
|
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.
|
|
| Floor5 hxj | Posted 2005-04-14 00:00 |
| 中级用户 Posts 66 Credits 377 | |
|
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.
|
|
| Floor6 chenhui530 | Posted 2005-04-14 00:00 |
| 高级用户 Posts 273 Credits 772 | |
|
Haha~Funny~The LZ is so cute
|
|
| Floor7 siyuer | Posted 2005-04-14 00:00 |
| 初级用户 Posts 10 Credits 133 | |
|
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^_^
|
|
| Floor8 siyuer | Posted 2005-04-14 00:00 |
| 初级用户 Posts 10 Credits 133 | |
|
Or as the second floor said, echo y | choice
|
|
| Floor9 hxj | Posted 2005-04-14 00:00 |
| 中级用户 Posts 66 Credits 377 | |
|
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. |
|
| Floor10 JonePeng | Posted 2005-04-14 00:00 |
| 金牌会员 Posts 1,883 Credits 4,562 From 广东广州 | |
The following is the statement from hxj on 2005-4-13 22:03:58: 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. |
|
| Floor11 tatami | Posted 2005-04-15 00:00 |
| 初级用户 Posts 5 Credits 120 | |
|
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
|
|
| Floor12 siyuer | Posted 2005-04-19 00:00 |
| 初级用户 Posts 10 Credits 133 | |
The following is the speech of hxj on April 14, 2005, 20:23:44: I don't know if the author of the quoted post has tested it on his own machine. If not, don't talk casually! |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |