中国DOS联盟论坛

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-25 04:53
47,813 topics / 349,918 posts / today 1 new / 48,274 members
DOS批处理 & 脚本技术(批处理室) » What methods are there for receiving user input in batch processing?
Printable Version  840 / 3
Floor1 hulongzhuo Posted 2007-04-20 03:20
中级用户 Posts 135 Credits 294
In pure DOS mode, the following statements can't be used:
set /p confrim=yes or no?(y/n):
if %confirm% == y goto ..
if %confirm% == n goto..

That is, wait on the screen to get a variable entered by the user. I know I can use CHOOSE, but it's an external command. I'd like to know what other methods there are to achieve the function above.
Floor2 hulongzhuo Posted 2007-04-20 04:23
中级用户 Posts 135 Credits 294
Floor3 hulongzhuo Posted 2007-04-20 05:32
中级用户 Posts 135 Credits 294
No one answering?
Floor4 zhoushijay Posted 2007-04-20 07:34
高级用户 Posts 375 Credits 845
set /p confrim=yes or no?(y/n):
if %confirm% == y goto ..
if %confirm% == n goto..

This can do it, but there is one problem: if the user enters some other character, then %confirm% is neither equal to Y nor equal to n. So add another bit of code:

:re
set /p confrim=yes or no?(y/n):
if /i %confirm% == y goto ..
if /i %confirm% == n goto..

if /i %confirm% neq y goto :re
if /i %confirm% neq n goto :re
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023