Batch file 为什么在set/P用户提示后批处理脚本一直退出?

Batch file 为什么在set/P用户提示后批处理脚本一直退出?,batch-file,Batch File,看起来您需要一个暂停命令。您的代码正在正确执行,但是在看到结果之前,没有任何东西可以阻止代码退出 @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 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

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

您不是115。1968年你出生的时候我8岁,那是阿波罗11号的前一年。如果您是115岁,您将感染恶意软件-Cov-2病毒。请删除导致窗口退出的
exit
语句。如果要在提示后退出,请使用
暂停
而不是退出。
@Echo off
Echo This message will not be displayed.
cls
Echo This message will be displayed.
pause
exit