假设我有一个批处理文件:
echo Would you like to open text.txt? (y/n)
set/p "cho=>"
if %cho%==Y goto OPENFILE
if %cho%==y goto OPENFILE
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:OPENFILE
:END
我如何批量打开文本文件?
答案 0 :(得分:1)
根据我之前的评论,以下是三个示例:
Choice /M "Would you like to open text.txt"
If ErrorLevel 2 GoTo :END
"text.txt"
:END
Choice /M "Would you like to open text.txt"
If ErrorLevel 2 GoTo :END
Start "" "text.txt"
:END
Choice /M "Would you like to open text.txt"
If ErrorLevel 2 GoTo :END
Start "" /Wait "text.txt"
:END
您会注意到,我使用了更合适的Choice
命令而不是Set /P
,这几乎无法控制最终用户输入的内容。