为什么设置P用户提示后批处理脚本一直退出?

问题描述 投票:0回答:1
@echo off
cls

echo Hello, there! Today is
date /t
echo and the current time is 
time /t

echo I'm so glad to meet you. My name is Hal 10000.
set /p name=What's your name?

cls

echo Well hello, %name%
echo Hey, %name%, & set /p "age"="how old are you in years?"
echo Well that's just great! I'm actually 115 today.
echo I look pretty good, huh!?
echo Well, gotta go, by!

exit
batch-file
1个回答
0
投票

看来你需要一个 暂停 命令。你的代码正在正确执行,但是在你看到结果之前,没有什么可以阻止代码退出。

@Echo off
Echo This message will not be displayed.
cls
Echo This message will be displayed.
pause
exit

添加一个 暂停 在...之前 退出 将显示你的结果,直到按下按钮。

© www.soinside.com 2019 - 2024. All rights reserved.